Buffering problem using subprocess module

D

Dr. Who

I am using the subprocess module in 2.4. Here's the fragment:

bufcaller.py:
import sys, subprocess
proc = subprocess.Popen('python bufcallee.py', bufsize=0, shell=True,
stdout=subprocess.PIPE)
for line in proc.stdout:
sys.stdout.write(line)

bufcallee.py:
import time
print 'START'
time.sleep(10)
print 'STOP'

Although the documentation says that the output should be unbuffered
(bufsize=0) the program (bufcaller) pauses for 10 seconds and then
prints START immediately followed by 'STOP' rather than pausing 10
seconds in between them. Note that I made bufcallee a Python script
for ease of the example but in the real-world problem I am trying to
solve it is simply an executable.

Any ideas?
Jeff
 
D

Dr. Who

Unfortunatley that doesn't help. Even when callee is started using the
-u, I get the same behavior.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top