Skip to content

Commit 2344f1c

Browse files
committed
hw-mgmt: scripts: Fix peripheral/thermal updater service crash on exit.
Sometimes, on peripheral/thermal updater service can be failed because of race condition in logging subsystem. It happens on log emit in signal handler. Fix: move all log from sig handler to main loop Bug: 4833200 Signed-off-by: Oleksandr Shamray <oleksandrs@nvidia.com>
1 parent 250ddb1 commit 2344f1c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

usr/usr/bin/hw_management_peripheral_updater.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class CONST(object):
8787

8888

8989
EXIT = threading.Event()
90+
_sig_condition_name = ""
9091

9192

9293
def _build_attrib_list():
@@ -569,10 +570,13 @@ def handle_shutdown(sig, _frame):
569570
@param sig: Signal number
570571
@param _frame: Unused frame
571572
"""
572-
EXIT.set()
573-
LOGGER.notice("hw-management-peripheral-updater: received signal {}, stopping main loop".format(sig))
573+
global _sig_condition_name
574+
try:
575+
_sig_condition_name = signal.Signals(sig).name
576+
except (ValueError, AttributeError):
577+
_sig_condition_name = str(sig)
574578

575-
return
579+
EXIT.set()
576580

577581

578582
def main():
@@ -661,7 +665,7 @@ def main():
661665

662666
EXIT.wait(timeout=1)
663667

664-
LOGGER.notice("hw-management-peripheral-updater: stopped main loop")
668+
LOGGER.notice("hw-management-peripheral-updater: stopped main loop ({})".format(_sig_condition_name))
665669
return
666670

667671

usr/usr/bin/hw_management_thermal_updater.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def _build_thermal_config():
153153
LOGGER = None
154154

155155
EXIT = threading.Event()
156+
_sig_condition_name = ""
156157

157158
# ----------------------------------------------------------------------
158159

@@ -483,10 +484,12 @@ def handle_shutdown(sig, _frame):
483484
@param sig: Signal
484485
@param _frame: Unused frame
485486
"""
487+
global _sig_condition_name
488+
try:
489+
_sig_condition_name = signal.Signals(sig).name
490+
except (ValueError, AttributeError):
491+
_sig_condition_name = str(sig)
486492
EXIT.set()
487-
LOGGER.notice("hw-management-thermal-updater: received signal {}, stopping main loop".format(sig))
488-
489-
return
490493

491494
# ----------------------------------------------------------------------
492495

@@ -569,7 +572,7 @@ def main():
569572

570573
EXIT.wait(timeout=1)
571574

572-
LOGGER.notice("hw-management-thermal-updater: stopped main loop")
575+
LOGGER.notice("hw-management-thermal-updater: stopped main loop ({})".format(_sig_condition_name))
573576

574577

575578
if __name__ == '__main__':

0 commit comments

Comments
 (0)