How do I control output buffering on Win32?
Fredrik Lundh
fredrik at pythonware.com
Fri Aug 15 11:01:21 EDT 2008
Grant Edwards wrote:
> When I ssh in to my Windows XP box and run Python apps, output
> from "print" and and "sys.stdout.write()" is being buffered so
> that none of the output shows up until the program exits.
>
>>From within my program how do I set output buffering to either
> line-buffered or un-buffered? [I'm looking for the equivalent
> of the C stdio "setbuf" call.]
I'm not sure you can do that from within the program [1]; to do it from
the outside, set the PYTHONUNBUFFERED environment variable to something,
or pass "-u" to the interpreter.
</F>
1) well, I suppose you could replace sys.stdout with a thin wrapper that
does flush after each write, or play with os.fdopen.
More information about the Python-list
mailing list