[Twisted-Python] handling SIGCHLD
Hi, I have a twisted service that needs to fork child processes to do tasks, after which they will exit. I wrote a signal handler for SIGCHLD but it didn't seem to be called. I read something about twisted installing its own signal handlers that may conflict. Is this true? How would you recommend handling a SIGCHLD in twisted? Many thanks, Mike -- Michael P. Soulier <msoulier@digitaltorque.ca> "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction." --Albert Einstein
Hi,
I have a twisted service that needs to fork child processes to do tasks, after which they will exit. I wrote a signal handler for SIGCHLD but it didn't seem to be called. I read something about twisted installing its own signal handlers that may conflict. Is this true?
How would you recommend handling a SIGCHLD in twisted?
You should probably just use reactor.spawnProcess to fork processes: it implements the process handling for you, and has its own SIGCHLD handler that does the right thing, so you don't have to maintain your own. -Itamar
On 08/06/10 Itamar Turner-Trauring said:
You should probably just use reactor.spawnProcess to fork processes: it implements the process handling for you, and has its own SIGCHLD handler that does the right thing, so you don't have to maintain your own.
The problem is that I'm using the multiprocessing module right now. Mike -- Michael P. Soulier <msoulier@digitaltorque.ca> "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction." --Albert Einstein
On 05:16 pm, msoulier@digitaltorque.ca wrote:
On 08/06/10 Itamar Turner-Trauring said:
You should probably just use reactor.spawnProcess to fork processes: it implements the process handling for you, and has its own SIGCHLD handler that does the right thing, so you don't have to maintain your own.
The problem is that I'm using the multiprocessing module right now.
Aside from switching from multiprocessing to spawnProcess (or Ampoule), you might want to take a look at http://stackoverflow.com/questions/1470850/twisted-network-client- with-multiprocessing-workers/1472271#1472271 Jean-Paul
Two options: 1. (as Itamar notes) use spawnProcess for all your process spawning needs 2. reactor.run(installSignalHandlers = False) and do your own signal handling For option #2, you'll almost certainly want to install SIGTERM and SIGINT handlers which call reactor.stop(). Jason On Tue, Jun 8, 2010 at 12:36 PM, Michael P. Soulier < msoulier@digitaltorque.ca> wrote:
Hi,
I have a twisted service that needs to fork child processes to do tasks, after which they will exit. I wrote a signal handler for SIGCHLD but it didn't seem to be called. I read something about twisted installing its own signal handlers that may conflict. Is this true?
How would you recommend handling a SIGCHLD in twisted?
Many thanks, Mike -- Michael P. Soulier <msoulier@digitaltorque.ca> "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction." --Albert Einstein
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkwOcYkACgkQKGqCc1vIvggbUACfY8xqgU2LLOrs0cfR7HngUqmc LOQAoKkur5+DK8lcZ+q6qWDtjqIpX3Ov =XM/4 -----END PGP SIGNATURE-----
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Jason Rennie Research Scientist, ITA Software 617-714-2645 http://www.itasoftware.com/
participants (4)
-
exarkun@twistedmatrix.com
-
Itamar Turner-Trauring
-
Jason Rennie
-
Michael P. Soulier