Moving multiprocessing.Manager to the correct sub-process (#13377)

Why I did it
There is a queue in sysmonitor.py that is created based on an object of multiprocessing.Manager.
After performing fast-reboot, system health monitor is being shut down, what causes this Manager to be shut down as well, since it is a child-process of healthd.
That's why I moved the creation of this Manager from the top of the file to the function Sysmonitor.system_service() (The only place it is used), to make Manager a child-process of Sysmonitor, instead of Healthd. This way both the queue (the Manager) and the processes that uses this queue will be child-processes of the same process, and the problematic scenario of sysmonitor sending messages to a dead queue will not be possible.

How I did it
Removed the definition of manager as global and moved it to system_service() function

How to verify it
Perform a fast reboot and verify the traceback issue is fixed
This commit is contained in:
Tomer Shalvi 2023-01-17 18:43:49 +02:00 committed by mssonicbld
parent 982a82f07a
commit 03804ad8d2

View File

@ -19,7 +19,6 @@ spl_srv_list = ['database-chassis', 'gbsyncd']
SELECT_TIMEOUT_MSECS = 1000
QUEUE_TIMEOUT = 15
TASK_STOP_TIMEOUT = 10
mpmgr = multiprocessing.Manager()
logger = Logger(log_identifier=SYSLOG_IDENTIFIER)
@ -420,6 +419,7 @@ class Sysmonitor(ProcessTaskBase):
self.state_db = swsscommon.SonicV2Connector(host='127.0.0.1')
self.state_db.connect(self.state_db.STATE_DB)
mpmgr = multiprocessing.Manager()
myQ = mpmgr.Queue()
try:
monitor_system_bus = MonitorSystemBusTask(myQ)