Detect hung apps spawned from python

Just just at xs4all.nl
Mon Jun 2 17:17:03 CEST 2003


In article <3edb668b$0$13744$afc38c87 at news.easynet.co.uk>,
 "David Stubbs" <david at snsys.com> wrote:

> Sorry,
> 
> I was a bit vague. I do use os.listdir() to build up the list. I meant that
> I execute a script from within each of these directories with the
> os.system() call. As the call to os.system() is blocking, I'd like some way
> to detect if the spawned process hangs, and if so recover control.
> 
> Does anyone know an easy way of traversing a list of python scripts,
> executing each one in turn, checking the return value, and also safeguarding
> against scripts that never return control back to the host script?
> 
> I'm just trying to create a simple test harness, and so far have it looking
> quite good except that if one of the individual tests crash then my test
> harness sits patiently waiting forever, which obviously isn't good as it
> then requires user intervention.

Look at the popen2.py module. Either you can use it as-is, or (depending 
on your specific needs) you can use it as inspiration how to deal with 
external processes.

Just




More information about the Python-list mailing list