Why does producer delay halt shell pipe?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dwhall

    Why does producer delay halt shell pipe?

    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.writ e("hello.\r\n ")
    time.sleep(0.00 0001)

    #! /usr/bin/env python
    import sys
    if __name__ == "__main__":
    line = sys.stdin.readl ine()
    while line:
    sys.stdout.writ e(line.upper())
    line = sys.stdin.readl ine()

    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
  • Nanjundi

    #2
    Re: Why does producer delay halt shell pipe?

    On Dec 11, 1:05 pm, dwhall <dwhall...@gmai l.comwrote:
    filters. Is there any way to write the filter to make this work?
    >
    thanks,
    >
    !!Dean
    turn off python buffering & it should work.
    export PYTHONUNBUFFERE D=t

    n'joy
    -N

    Comment

    • dwhall

      #3
      Re: Why does producer delay halt shell pipe?

      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 PYTHONUNBUFFERE D=t

      Comment

      Working...