Cancel Join After Sys.exit In Multiprocessing
Solution 1:
You can avoid this by setting the daemon
property to True
on your child processes. From the multiprocessing.Process
docs (emphasis mine):
daemon
The process’s daemon flag, a Boolean value. This must be set before start() is called.
The initial value is inherited from the creating process.
When a process exits, it attempts to terminate all of its daemonic child processes.
Note that a daemonic process is not allowed to create child processes. Otherwise a daemonic process would leave its children orphaned if it gets terminated when its parent process exits. Additionally, these are not Unix daemons or services, they are normal processes that will be terminated (and not joined) if non-daemonic processes have exited.
So if p.daemon == True
, your parent process will just kill your child process, rather than join
it. Note, though, that your daemonic processes cannot create their own children (as stated in the docs).
Solution 2:
I solved this by using os._exit(1)
instead of sys.exit(1)
.
- Pyqt5 Cannot Update Progress Bar From Thread And Received The Error "cannot Create Children For A Parent That Is In A Different Thread"
- Pyqt Signal With Arguments Of Arbitrary Type / Pyqt_pyobject Equivalent For New-style Signals
- Python - How To Detect When User Closes A Console Application Via "x" Button
Post a Comment for "Cancel Join After Sys.exit In Multiprocessing"