By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,536 Members | 1,504 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,536 IT Pros & Developers. It's quick & easy.

Why does producer delay halt shell pipe?

P: n/a
I have 2 python scripts: examples of a producer and a filter,
respectively:

#! /usr/bin/env python
import sys, time
if __name__ == "__main__":
while True:
sys.stdout.write("hello.\r\n")
time.sleep(0.000001)

#! /usr/bin/env python
import sys
if __name__ == "__main__":
line = sys.stdin.readline()
while line:
sys.stdout.write(line.upper())
line = sys.stdin.readline()

I wish to use these programs in Bash, like so:

$ ./producer.py | ./filter.py

However, the producer's time delay makes this not work. If I remove
or reduce the delay, it works. In reality the producer has an
unavoidable one-second delay. I do NOT want to use popen or its
cousins because I want flexibility from the command line; I have many
filters. Is there any way to write the filter to make this work?

thanks,

!!Dean
Dec 11 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Dec 11, 1:05 pm, dwhall <dwhall...@gmail.comwrote:
filters. Is there any way to write the filter to make this work?

thanks,

!!Dean
turn off python buffering & it should work.
export PYTHONUNBUFFERED=t

n'joy
-N
Dec 11 '07 #2

P: n/a
Thanks, N, it works like a charm.

!!Dean

On Dec 11, 12:49 pm, Nanjundi <nanju...@gmail.comwrote:
turn off python buffering & it should work.
export PYTHONUNBUFFERED=t
Dec 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.