How can I implement a timeout with subprocess.Popen()?
No.Spam at Spam.none
Mon May 1 03:35:11 CEST 2006
I want my Python program to invoke a compiled C program, and capture the
Here's a fragment from a program that works, using subprocess.Popen:
p = Popen(execName, stdout=PIPE)
line = p.stdout.readline() # get next line
(Then I test for a certain unique phrase in line, and then break
if it occurs)
The above works fine as long as the target program runs for a little
while and then stops. But what if it does not stop? It might run
forever, with or without outputting any lines. How can I make this
robust? The keyword might not occur. The target might crash. It might
run forever, with or without text output.
I'm proud of http://ANNEvolve.sourceforge.net. If you want to write software,
or articles, or do testing or research for ANNEvolve, let me know.
Humans may know that my email address is: (but remove the 3 digit number)
zenguy at shaw666 dot ca
More information about the Python-list