<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Pascal Chambon a écrit :
<blockquote cite="mid:49F33FBA.1050101@gmail.com" type="cite">
<dl class="attribute">
<dt id="multiprocessing.Process.daemon">Hello everyone</dt>
</dl>
<br>
I've just read the doc of the (awesome) "multiprocessing" module, and
there are some little things I don't understand, concerning daemon
processes (see quotes below).<br>
<br>
When a python process exits, the page says it attempts to join all its
children. Is this just a design choice, or are there constraints behind
this ? Because normally, when a parent process exits, its child gets
adopted by init, and that can be useful for creating daemons, can't it ?<br>
<br>
Concerning daemons processes, precisely, the manual states that they
are all terminated when their parent process exits. But isn't it
contrary to the concept of dameons, which are supposed to have become
independent from their parent ? <br>
<br>
And I don't understand how "the initial value (of the "daemonic"
attribute) is inherited from the creating process", since "daemonic
processes are not allowed to create child processes". Isn't it the same
to say that "daemonic" is always false by default, then ?<br>
And finally, why can't daemonic processes have children ? If these
children get "orphaned" when the daemonic process gets terminated (by
its parent), they'll simply get adpoted by init, won't they ?<br>
<br>
Thanks a lot for helping me get rid of my confusion,<br>
regards,<br>
Pascal<br>
<br>
<br>
<dl class="attribute">
<dt id="multiprocessing.Process.daemon"><tt class="descname">=========QUOTES==========</tt></dt>
<dt id="multiprocessing.Process.daemon"><tt class="descname">daemon</tt><a
moz-do-not-send="true" class="headerlink"
href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Process.daemon"
title="Permalink to this definition">¶</a></dt>
<dd>
<p>The process’s daemon flag, a Boolean value. This must be set
before <a moz-do-not-send="true" title="multiprocessing.Process.start"
class="reference internal"
href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Process.start"><tt
class="xref docutils literal"><span class="pre">start()</span></tt></a>
is called.</p>
<p>The initial value is inherited from the creating process.</p>
<p>When a process exits, it attempts to terminate all of its
daemonic child
processes.</p>
<p>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.<br>
<br>
----------------------<br>
</p>
</dd>
</dl>
<pre>Similarly, if the child process is non-daemonic then the parent
process may hang on exit when it tries to join all its non-daemonic children.
--------------
Remember also that non-daemonic
processes will be automatically be joined.
</pre>
<pre wrap="">
<hr size="4" width="90%">
--
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a>
</pre>
</blockquote>
Allright, I guess I hadn't understand much about "daemonic processes"
in python's multiprocessing module. <br>
<br>
So, for those interested, here is a clarification of the concepts, as
far as I've understood - please poke me if I'm wrong somewhere.<br>
<pre>Usually, in Unix, daemon processes are processes which got disconnected from
their parent process and from terminals, and work in the background, often under a
different user identity.
The python multiprocessing module has the concept of "daemon" too, but this
time in reference to the "threading" module, in which dameons are just
threads that wont prevent the application termination, even if they are
still running. Thus, daemonic processes launched through multiprocessing
API are normal processes that will be terminated (and not joined) if
non-dameonic processes are all over.
Thus, not much in common between "traditionnal" *nix daemon processes, and python multiprocessing daemon processes.
Regards,
pascal
</pre>
</body>
</html>