Linux, Python, and pipes

Steinar Knutsen sk at fyemf.fys.ntnu.no
Mon Oct 4 11:27:23 EDT 1999


In article <7taffc$3m1$1 at nnrp1.deja.com>, <prestonlanders at my-deja.com>
wrote:

>Anyone know what's up with pipes and Python on Linux?  It seems that
>when trying to pipe the output of a Python program, the pipe does not
>start flowing until the Python program exits.  For programs with long
>running times and lots of log/debug output, that means you can't begin
>to look at the output until the program terminates.

STDOUT from Python is usually buffered, therefore the pipe won't start
flowing before the buffer is full. You can turn off the buffering by
giving the flag "-u" when starting the interpreter. (Another possibility
would of course be flushing STDOUT at fitting intervals.)
-- 
Steinar




More information about the Python-list mailing list