Multiprocessing package - tensorplay.multiprocessing
Warning
If the main process exits abruptly (e.g. because of an incoming signal),
Python’s multiprocessing sometimes fails to clean up its children.
It’s a known caveat, so if you’re seeing any resource leaks after
interrupting the interpreter, it probably means that this has just happened
to you.
Strategy management
Spawning subprocesses
Note
Available for Python >= 3.4.
This depends on the spawn start method in Python’s
multiprocessing package.
Spawning a number of subprocesses to perform some function can be done
by creating Process instances and calling join to wait for
their completion. This approach works fine when dealing with a single
subprocess but presents potential issues when dealing with multiple
processes.
Namely, joining processes sequentially implies they will terminate
sequentially. If they don’t, and the first process does not terminate,
the process termination will go unnoticed. Also, there are no native
facilities for error propagation.
The spawn function below addresses these concerns and takes care
of error propagation, out of order termination, and will actively
terminate processes upon detecting an error in one of them.
A SpawnContext is returned by spawn when called with join=False.

