Line buffering pipes

Shaun Jackman sjackman at
Sat Oct 30 01:10:34 CEST 2004

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')
    while True: print,
    while True: print tcpdump.readline(),
buffer mutiple lines before printing.

Please cc me in your reply. Thanks,

More information about the Python-list mailing list