In an answer to the question "Python Process Pool non-daemonic?" it is shown how to disable the daemon attribute of a process:
class NoDaemonProcess(multiprocessing.Process):
# make 'daemon' attribute always return False
def _get_daemon(self):
return False
def _set_daemon(self, value):
pass
daemon = property(_get_daemon, _set_daemon)
# We sub-class multiprocessing.pool.Pool instead of multiprocessing.Pool
# because the latter is only a wrapper function, not a proper class.
class MyPool(multiprocessing.pool.Pool):
Process = NoDaemonProcess
This allows for a process in a pool to start it's own child process, as explained in the original question.
In exchange for the flexibility of starting child processes, what costs is paid? If there were no costs, presumably the standard Pool would have used non-daemonic processes.
Note: this question is based on a highly upvoted comment that went unaddressed, so I decided to convert it to a question.