I
I. Myself
I want my Python program to invoke a compiled C program, and capture the
text output.
Here's a fragment from a program that works, using subprocess.Popen:
p = Popen(execName, stdout=PIPE)
while(1):
line = p.stdout.readline() # get next line
outfile.write(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.
Thanks,
Mitchell Timin
--
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
text output.
Here's a fragment from a program that works, using subprocess.Popen:
p = Popen(execName, stdout=PIPE)
while(1):
line = p.stdout.readline() # get next line
outfile.write(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.
Thanks,
Mitchell Timin
--
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