File tree 1 file changed +14
-10
lines changed
platform/mellanox/mlnx-platform-api/sonic_platform
1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 31
31
from . import utils
32
32
from .device_data import DeviceDataManager
33
33
import re
34
+ import time
34
35
except ImportError as e :
35
36
raise ImportError (str (e ) + "- required module not found" )
36
37
37
- MAX_SELECT_DELAY = 3600
38
38
39
39
RJ45_TYPE = "RJ45"
40
40
@@ -387,26 +387,30 @@ def get_change_event(self, timeout=0):
387
387
self .sfp_event .initialize ()
388
388
389
389
wait_for_ever = (timeout == 0 )
390
+ # select timeout should be no more than 1000ms to ensure fast shutdown flow
391
+ select_timeout = 1000.0 if timeout >= 1000 else float (timeout )
390
392
port_dict = {}
391
393
error_dict = {}
392
- if wait_for_ever :
393
- timeout = MAX_SELECT_DELAY
394
- while True :
395
- status = self .sfp_event .check_sfp_status (port_dict , error_dict , timeout )
396
- if bool (port_dict ):
394
+ begin = time .time ()
395
+ while True :
396
+ status = self .sfp_event .check_sfp_status (port_dict , error_dict , select_timeout )
397
+ if bool (port_dict ):
398
+ break
399
+
400
+ if not wait_for_ever :
401
+ elapse = time .time () - begin
402
+ if elapse * 1000 > timeout :
397
403
break
398
- else :
399
- status = self .sfp_event .check_sfp_status (port_dict , error_dict , timeout )
400
404
401
405
if status :
402
406
if port_dict :
403
407
self .reinit_sfps (port_dict )
404
- result_dict = {'sfp' :port_dict }
408
+ result_dict = {'sfp' : port_dict }
405
409
if error_dict :
406
410
result_dict ['sfp_error' ] = error_dict
407
411
return True , result_dict
408
412
else :
409
- return True , {'sfp' :{}}
413
+ return True , {'sfp' : {}}
410
414
411
415
def reinit_sfps (self , port_dict ):
412
416
"""
You can’t perform that action at this time.
0 commit comments