Processes with timeout
Ivan Voras
iv at an.voras.fer
Mon Apr 19 15:34:48 EDT 2004
Markus Franz wrote:
> How can I make it sure that every child-process terminates after x senconds
> (wether it has finished or not)?
You can toy around with signals. From outside the child process, you can
send it SIGTERM after some time has passed (and catch it in the process).
From inside the process, you can use SIGALARM to track when the time has
expired. Or you can combine the two.
Or, you can start a "watchdog thread" (a thread that mostly sleep()-s, but
now and then checks the time)
More information about the Python-list
mailing list