mirror of
https://github.com/clearml/clearml
synced 2025-04-22 15:25:22 +00:00
Fix creating subprocess from a daemon process
This commit is contained in:
parent
1c1fecf7d0
commit
3890477056
@ -206,7 +206,24 @@ class BackgroundMonitor(object):
|
||||
d.set_subprocess_mode()
|
||||
BackgroundMonitor._main_process = Process(target=cls._background_process_start, args=(id(task), ))
|
||||
BackgroundMonitor._main_process.daemon = True
|
||||
# Hack allow to create daemon subprocesses (even though python doesn't like it)
|
||||
un_daemonize = False
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
from multiprocessing import current_process
|
||||
if current_process()._config.get('daemon'): # noqa
|
||||
un_daemonize = current_process()._config.get('daemon') # noqa
|
||||
current_process()._config['daemon'] = False # noqa
|
||||
except BaseException:
|
||||
pass
|
||||
BackgroundMonitor._main_process.start()
|
||||
if un_daemonize:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
from multiprocessing import current_process
|
||||
current_process()._config['daemon'] = un_daemonize # noqa
|
||||
except BaseException:
|
||||
pass
|
||||
# wait until subprocess is up
|
||||
if wait_for_subprocess:
|
||||
cls._sub_process_started.wait()
|
||||
|
Loading…
Reference in New Issue
Block a user