Line buffering pipes

Shaun Jackman sjackman at gmail.com
Fri Oct 29 21:10:15 EDT 2004


I've found in help( 'open') that specifying 1 as the buffer size
indicates line buffering. I've tried this, but the same non-line
buffered behaviour persists. I've tried disabling buffering
altogether, specifying 0 as the buffer size, to no avail.

Python 2.3.4

Please cc me in your reply. Thanks,
Shaun

On Fri, 29 Oct 2004 16:10:34 -0700, Shaun Jackman <sjackman at gmail.com> wrote:
> I'm reading from a tcpdump pipe. I want to receive one line from the
> pipe as soon as its available from tcpdump. Something is buffering the
> pipe though, so I am receiving nothing, then multiple lines in a big
> batch. I thought this was the inherent buffering of next(), but it
> affects readline too.
> 
> For example,
>     tcpdump = os.popen( 'sudo tcpdump', 'r')
> both
>     while True: print tcpdump.next(),
> and
>     while True: print tcpdump.readline(),
> buffer mutiple lines before printing.
> 
> Please cc me in your reply. Thanks,
> Shaun



More information about the Python-list mailing list