Line buffering pipes

Shaun Jackman sjackman at gmail.com
Fri Oct 29 19:10:34 EDT 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')
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