Subprocess and time-out

G

Gilles Lenfant

Hi,

Grabbing the various docs of Python, I didn't find how to do this :

I Use popen2 to run wvware that transforms lots of M$ word docs to plain
text. Sometimes wvware runs in a deadlock and I can't control this from
Python app.

I need to stop wvware processing after 30 seconds (considered
deadlocked) and to process the next file.

Unfortunately, I didn't find any pythonic stuff to control the time
spent runnning subprocesses (and kill'em if needed) launched with popen.

An hint is welcome. Many thanks by advance.
 
J

Jeremy Sanders

Grabbing the various docs of Python, I didn't find how to do this :

I Use popen2 to run wvware that transforms lots of M$ word docs to plain
text. Sometimes wvware runs in a deadlock and I can't control this from
Python app.

I need to stop wvware processing after 30 seconds (considered deadlocked)
and to process the next file.

Unfortunately, I didn't find any pythonic stuff to control the time spent
runnning subprocesses (and kill'em if needed) launched with popen.

An hint is welcome. Many thanks by advance.

Is this Unix? If you're using the Popen3/Popen4 objects from popen2
module, you could take the pid of the popened process, and fork your
program. In the forked child process you could wait for an interval, then
do os.wait with W_NOHANG to see whether the process has stopped, and if
not kill it with os.kill.

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top