Multiprocessing.Process Daemonic Behavior
John L. Stephens
lists.jkstephens at gmail.com
Wed Mar 16 06:02:02 EDT 2011
On 3/15/2011 11:19 PM, James Mills wrote:
> On Wed, Mar 16, 2011 at 12:34 PM, John L. Stephens
> <lists.jkstephens at gmail.com> wrote:
>> I would have expected the daemonic children processes to terminate with the
>> parent process, regardless of how the parent process terminates, either
>> normally or forcefully.
> As I understand it. If you forcibly kill the parent process
> with the KILL signal then any child procesases that were
> created become zombies. You also can't handle the KILL
> signal in your application (nor can the multiprocessing library)
> and so it therefore cannot cleanup and terminate any child
> processes in the normal way.
>
> cheers
> James
>
So as I have contemplated this in the wee hours of the morning (risking
zombie status myself I might add), my rationale for the behavior I am
seeing is thus:
As the parent process terminates 'normally' (either through normal
termination or SIGINT termination), mulitprocessing steps in and
performs child process cleanup via the x.terminate() method. If the
parent terminates any other way, multiprocessing doesn't have the
opportunity to cleanup.
I would have thought (silly me) the child process would also monitor his
parent process, and when the child can no longer 'see' or 'sense the
presence' of its parent, it too would terminate.
I can certainly make the children monitor the parent as well, I was just
hoping I wouldn't have to put in additional code and overhead.
John
More information about the Python-list
mailing list