Multiprocessing: killing children when parent dies

Chris Angelico rosuav at gmail.com
Fri Dec 2 10:13:34 EST 2011


On Sat, Dec 3, 2011 at 2:05 AM, Mihai Badoiu <mbadoiu at gmail.com> wrote:
> In the multiprocessing module, on a Process p, by just doing p.daemon=1
> before p.start(), we can make the child die when the parent exits.  However,
> the child does not die if the parent gets killed.
> How can I make sure the child die when the parent gets killed?

Are you in control of the killing of the parent? One easy way would be
to catch the signal (say SIGINT) and initiate an orderly shutdown,
signalling the children first.

ChrisA



More information about the Python-list mailing list