On Wed, 7 Nov 2012 09:52:35 +0900, Stephen Bunn <>
declaimed the following in gmane.comp.python.general:
> I'm looking for some help with multiprocessing. Essentially what I'm
> trying to do is the following:
>
> 1. create a main process that gets daemonized
> 2. spawn two subprocess that live for the life of the daemon
That sounds backwards to me (presuming daemonized /processes/ are
equivalent to daemonized /threads/). In the threading module, a daemon
thread hangs around until the parent non-daemon thread exits.
From the 2.7 documentation of multiprocessing:
-=-=-=-
daemon
The process’s daemon flag, a Boolean value. This must be set before
start() is called.
The initial value is inherited from the creating process.
When a process exits, it attempts to terminate all of its daemonic child
processes.
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. Additionally, these are
not Unix daemons or services, they are normal processes that will be
terminated (and not joined) if non-daemonic processes have exited.
-=-=-=-
Problem is, you can't reverse your scheme since, if the "step" two
processes were the daemons, they would not be allowed to do
> 3. each subprocess creates children that do heavy work and exit when
> the work is done
this step.
The only reliable means is for all subprocesses to be looking for a
signal of some sort which tells them to exit on their own part.
--
Wulfraed Dennis Lee Bieber AF6VN
HTTP://wlfraed.home.netcom.com/