multiproccess: What is the Dameon flag?

MRAB python at
Wed Sep 16 13:55:35 CEST 2009

Allen Fowler wrote:
>>> What is the Daemon flag and when/why would I want to use it?
>> From the documentation: "When a process exits, it attempts to
>> terminate all of its daemonic child processes.".
>> Sometimes you want the main process to wait for its worker
>> processes to terminate before terminating itself so that you can be
>> sure that everything (including resources they might use) has been
>> tidied up. Other times there's nothing to tidy up so you just want
>> the worker processes to terminate when the main process terminates.
>> In the second case the worker process are known as daemon
>> processes.
> Thank you.
> Two clarification questions:
> 1) So, without that flag the parent process could finish before the
> kids, and the kids would keep running?
The parent process could finish what it's doing but not terminate (quit)
because it's waiting for non-daemon child processes to terminate.

> 2) If you use kid.join() in parent, the parent will always wait for
> kid to finish before continuing? (And eventually quitting)

More information about the Python-list mailing list