This is running on Windows Vista Home 32b with Service Pack 2 I am actively testing it on Mac, and Linux
I have one python script [A] that uses subprocess to run another python script [B]
process = subprocess.Popen(action, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
bufsize=-1)
out = process.stdout.readline()
print out
I use [A] to run [B]
[B] comes from the command line, so can be any script what so ever
when [B] is a the following python script
#file = 'bufftest.py"
msg = "X"
x = 1024
y = 1024
z = 1
while (z < y):
print msg * x
z = z + 1
both running from the command line, and from [A], it produces, all the output
when [B] is a program that I didn't write, and I cannot show code for, run at the command line it produces fifteen lines of output however, when run from [A], it produces only the first line
The program I didn't write prints output like this
sys.stdout.write("Line01")
# 02-14
sys.stdout.write("Line15")
It originally printed output with print, sys,stdout.write() And I address sys.stdoutput.flush() to try to resolve this.
Thank you.
readline
(nos
at the end!), and it calls it only once. But then you say that your code behaves correctly (i.e. reads multiple lines) when it tries to capture the output ofbufftest.py
. That's not possible with the code you've posted, so I'm a bit confused. – senderle May 31 '12 at 15:16out = process.stdout.readline()
to only get one line ... I'm a little surprised your first script works ... – mgilson May 31 '12 at 15:16