Again, I could be taking the wrong approach: Here is the scenerao: 1) Why the pooling Each compute node can run 2 processes at the same time (big processes) The compute node must accept more jobs then it can run, and hold the waiting tasks in a queue. (logically similar problem to database connections, except, compute connections are used instead). 2) why not spawnProcess The code said that spawnprocess is broken on windows. (I could be looking in the wrong place, twisted is a big codebase :-) I fell back to using popen2 in a thead managed by the "thread pool" I am always open to refactoring a design. Windows is my prime platform, but I also must support the UNIX platforms. Hope this helps clairify what I am doing (not saying that I am taking the correct approach with twisted, but I am trying and willing to change to do it the twisted way :-) Thank you very much, Mike ---------------------------------------------------------------- Michael Schneider Senior Software Engineering Consultant UGS PLM Solutions - an EDS Company "The Greatest Performance Improvement Is the transitioning from a non-working state to the working state"
-----Original Message----- From: twisted-python-admin@twistedmatrix.com [mailto:twisted-python-admin@twistedmatrix.com]On Behalf Of Jp Calderone Sent: Thursday, February 12, 2004 10:27 AM To: twisted-python@twistedmatrix.com Subject: Re: [Twisted-Python] What is the "Twisted" way to kill stuck child process
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.
Problem: 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.
Jp