MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / start_proc_mask_signal

Function start_proc_mask_signal

tensorpack/utils/concurrency.py:217–240  ·  view source on GitHub ↗

Start process(es) with SIGINT ignored. Args: proc: (mp.Process or list) Note: The signal mask is only applied when called from main thread.

(proc)

Source from the content-addressed store, hash-verified

215
216
217def start_proc_mask_signal(proc):
218 """
219 Start process(es) with SIGINT ignored.
220
221 Args:
222 proc: (mp.Process or list)
223
224 Note:
225 The signal mask is only applied when called from main thread.
226 """
227 if not isinstance(proc, list):
228 proc = [proc]
229
230 with mask_sigint():
231 for p in proc:
232 if isinstance(p, mp.Process):
233 if sys.version_info < (3, 4) or mp.get_start_method() == 'fork':
234 log_once("""
235Starting a process with 'fork' method is efficient but not safe and may cause deadlock or crash.
236Use 'forkserver' or 'spawn' method instead if you run into such issues.
237See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods on how to set them.
238""".replace("\n", ""),
239'warn') # noqa
240 p.start()
241
242
243def subproc_call(cmd, timeout=None):

Callers 6

_before_trainMethod · 0.90
trainFunction · 0.90
_setup_graphMethod · 0.85
_before_trainMethod · 0.85
_start_processesMethod · 0.85
reset_stateMethod · 0.85

Calls 3

mask_sigintFunction · 0.85
log_onceFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…