I came across a problem when using subprocess.Popen. I went through the problem here. When I add the following edit to the fake_utility.py i.e add stderr=subprocess.PIPE in subprocess.Popen:
#fake_utility.py
import time
i = 0
while True:
print hex(i)*512
i += 1
time.sleep(0.5)
#python interpreter
import subprocess
proc = subprocess.Popen(['python','fake_utility.py'],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for err in proc.stderr:
print "err::", err
for line in proc.stdout:
print "test:", line.rstrip()
the program doesnt respond. When I press a Ctrl-C, I get the following:
Traceback (most recent call last):
File "run_fake_utility.py", line 6, in <module>
err = proc.stderr.readline()
KeyboardInterrupt
It is being blocked in proc.stderr.readline(). If I remove the line reading from proc.stderr, the program runs fine.
What is the possible error? I am using Python2.6.