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

Function ensure_proc_terminate

tensorpack/utils/concurrency.py:147–169  ·  view source on GitHub ↗

Make sure processes terminate when main process exit. Args: proc (multiprocessing.Process or list)

(proc)

Source from the content-addressed store, hash-verified

145
146
147def ensure_proc_terminate(proc):
148 """
149 Make sure processes terminate when main process exit.
150
151 Args:
152 proc (multiprocessing.Process or list)
153 """
154 if isinstance(proc, list):
155 for p in proc:
156 ensure_proc_terminate(p)
157 return
158
159 def stop_proc_by_weak_ref(ref):
160 proc = ref()
161 if proc is None:
162 return
163 if not proc.is_alive():
164 return
165 proc.terminate()
166 proc.join()
167
168 assert isinstance(proc, mp.Process)
169 atexit.register(stop_proc_by_weak_ref, weakref.ref(proc))
170
171
172def enable_death_signal(_warn=True):

Callers 5

simulator.pyFile · 0.90
trainFunction · 0.90
_setup_graphMethod · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls 1

registerMethod · 0.80

Tested by

no test coverage detected