MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / enable_death_signal

Function enable_death_signal

tensorpack/utils/concurrency.py:172–191  ·  view source on GitHub ↗

Set the "death signal" of the current process, so that the current process will be cleaned with guarantee in case the parent dies accidentally.

(_warn=True)

Source from the content-addressed store, hash-verified

170
171
172def enable_death_signal(_warn=True):
173 """
174 Set the "death signal" of the current process, so that
175 the current process will be cleaned with guarantee
176 in case the parent dies accidentally.
177 """
178 if platform.system() != 'Linux':
179 return
180 try:
181 import prctl # pip install python-prctl
182 except ImportError:
183 if _warn:
184 log_once('"import prctl" failed! Install python-prctl so that processes can be cleaned with guarantee.',
185 'warn')
186 return
187 else:
188 assert hasattr(prctl, 'set_pdeathsig'), \
189 "prctl.set_pdeathsig does not exist! Note that you need to install 'python-prctl' instead of 'prctl'."
190 # is SIGHUP a good choice?
191 prctl.set_pdeathsig(signal.SIGHUP)
192
193
194def is_main_thread():

Callers 6

runMethod · 0.90
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85

Calls 1

log_onceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…