[Twisted-Python] What is the "Twisted" way to kill stuck child process
exarkun at intarweb.us
Thu Feb 12 10:27:23 EST 2004
On Thu, Feb 12, 2004 at 08:57:07AM -0500, Schneider, Michael wrote:
> Hello All,
> I am making real progress with twisted. Thank you very much
> for the great project.
> I am creating a process launcher that runs on SGI, SUN, IBM AIX,
> HPUX, and windows 2000 and XP.
> I modified the adbapi.py file to pool jobs. It works great.
> Sometimes the launched c program will hang. (standard exe file).
> I want to launch a process with timeout value.
> Ex. I know that task X usually take 1200 seconds to run, but it
> will sometimes hang. If the exe has not finished running after
> 1500 seconds, I want to kill the job and notify the caller that
> their job timed out.
> What are some options for implementing this with twisted.
> NOTE: each process is launched in its own thread, so killing the
> thread is an option is that is required.
I don't understand this. Are you using reactor.spawnProcess() to start
these processes? If not, you should be. If so, it should be called from
the main thread, and the process can be killed with the usual means,
os.kill(pid). The PID is available, though I forget exactly where, probably
as processProtocol.transport.pid. You can use reactor.callLater to set up a
simple timeout so that processes are killed if they run for too long.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20040212/c6f6130b/attachment.pgp
More information about the Twisted-Python