multiprocessing Pool workers cannot create subprocesses

Ned Deily nad at acm.org
Fri Mar 18 16:29:58 EDT 2011


In article <4D838D28.5090705 at creativetrax.com>,
 Jason Grout <jason-python at creativetrax.com> wrote:
> The problem appears to be that multiprocessing sets its workers to have 
> the daemon flag set to True, which prevents workers from creating child 
> processes.  If I uncomment the line indicated in the code, I can create 
> child processes and the program works (it prints out the even numbers 
> from 0 to 18).
> 
> It makes me nervous to just change the daemon status of the process like 
> that, especially when I don't know the reason the workers have 
> daemon=True to begin with.  What is the reasoning behind that decision? 
>   What issues do we need to worry about if we just set the daemon mode 
> flag like in the above code?

http://docs.python.org/library/multiprocessing.html#multiprocessing.Proce
ss.daemon

"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."

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list