multiprocessing and SIGINT
gagsl-py2 at yahoo.com.ar
Sat Jan 10 08:15:22 CET 2009
En Fri, 09 Jan 2009 03:04:58 -0200, akineko <akineko at gmail.com> escribió:
> (2) test program with multiprocessing
> Both processes receives SIGINT.
> OS apparently distributes the SIGINT event to processes associated
> with the terminal.
Yes, to avoid that, the child process has to detach itself from the
terminal. I'd expect the multiprocessing module to do that for us - but it
doesn't. See http://www.onlamp.com/python/pythoncook2/solution.csp?day=1
> (3) signal handler
> I realized that I could assign a signal handler specific to a process
> by placing it to a worker method.
> def worker():
> # this process ignores SIGINT
> signal.signal(signal.SIGINT, signal.SIG_IGN)
> ... the rest ...
> (4) terminating the spawned process
> I needed to send a shutdown message to the process via a communication
> between two processes.
> You can use Process.terminate() to brutally kill the process but that
> is a last resort.
What about sending a signal, like SIGTERM?
More information about the Python-list