A multiprocessing context where proc.daemon is always False, and setting it to True is ignored. All processes will still be cleaned up though. For cleaning up, we use SIGINT (instead of the standard SIGTERM) such that the processes can do proper cleanup themselves.

See NonDaemonicSpawnProcess and NonDaemonicSpawnContext.

This is when you don’t want to use the default multiprocessing fork start method, but the spawn start method, but you also want that the started processes are never daemonic.


class returnn.util.multi_proc_non_daemonic_spawn.NonDaemonicSpawnProcess(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)[source]

This process is always non-daemon, even if proc.daemon=True is executed (like

Still, we make sure that the proc is cleaned up at exit. Instead of using SIGTERM as Python does for normal daemonic threads, we use SIGINT, to allow the subprocess to do proper cleanup, e.g. like cleaning up sub-sub procs. So the sub proc would not leave its children orphaned. Note, if SIGINT does nothing on the subproc, this will hang.

property daemon[source]

Return whether process is a daemon

pre_init_func: Callable[[], None] | None = None[source]
class returnn.util.multi_proc_non_daemonic_spawn.NonDaemonicSpawnContext(*, process_pre_init_func: Callable[[], None] | None = None)[source]

Spawn start methods, where all procs are non-daemonic.

Process(*args, **kwargs)[source]

create a new process