Skip to content Skip to sidebar Skip to footer

Let Parent Process Return Before Child Process Using Python Multiprocessing Library

When one creates Processes with multiprocessing library from python, the parent process waits for its children to return before it returns. In fact, the documentation recommends jo

Solution 1:

Just remove the process object from the _children set of the current process object, the the parent process will exit immediately.

Theh multiprocessing module manages child processes in a private set and join them when the current process exits. You can remove children from the set if you don't care of them.

process = multiprocessing.Process(target=proc_main)
multiprocessing.current_process()._children.discard(process)
exit(0)

Post a Comment for "Let Parent Process Return Before Child Process Using Python Multiprocessing Library"