Multiprocessing.Process Daemonic Behavior

Anssi Saari as at sci.fi
Fri Mar 18 06:23:31 EDT 2011


"John L. Stephens" <lists.jkstephens at gmail.com> writes:

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

Unless you handle the signal explicitly? Since SIGINT maps to
KeyboardInterrupt automatically, you basically handle SIGINT but
nothing else. A rude hack to your example with a handler for SIGTERM
which just raises KeyboardInterrupt resulted in the children getting
the SIGTERM 10 seconds afterwards. Which is after the sleep(10) call
finishes in your script.




More information about the Python-list mailing list