Detect hung apps spawned from python

Jeff Epler jepler at unpythonic.net
Mon Jun 2 16:59:02 CEST 2003


On Mon, Jun 02, 2003 at 01:55:39PM +0100, David Stubbs wrote:
> Hi,
> 
> I have a python app that builds a list of all subdirectories from the
> current directory, and then in turn runs a 'test.py' script from within each
> of these directories. I currently do this using os.system(). Is there any
> easy way of detecting apps that crashed, and terminating them if so? Ideally
> being able to set a time-out to wait for the application to finish would be
> good.
> 
> I think I could do it using CreateProcess, but, well, it just seems like
> overkill and that there'll be a much simpler method somewhere.

As far as I know, you'll have to use the Windows-specific APIs if you
want to do something like "kill this process if it takes longer than 30
seconds".  On Unix, you would use fork+exec and os.kill(), but as far as
I know these don't translate to the Windows world.

Jeff





More information about the Python-list mailing list