Queued stdout, flush() doesn't seems to help...

Dave Lajoie davelaj at videotron.ca
Tue Mar 8 00:03:34 EST 2005


Hello Everyone,

I have been using this piece of code to start an exec and "process" its stdout/stderror

import sys
import popen2
executable = r'execfile -arg1 -arg2'
r, w, e = popen2.popen3(executable)
r.flush()
w.flush()
e.flush()
x=0
# just print the 1000 first lines
while x<1000:
    sys.stdout.write(e.readline())
    sys.stdout.flush()
    sys.stdout.write(r.readline())
    sys.stdout.flush()

whenever running this code, the process starts up fine, but no print occurs as the exec is running.
Somehow, the print results shows up only when the process is stopped or when resuming ( thru the windows task list).

is there a way to get the print to show its results as as it is trapped by open3() function ( namely realtime printing ).

Does someone would have a solution for this problem?
Tx in advance for your help.

Dave.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050308/622cf5f8/attachment.html>


More information about the Python-list mailing list