I'm trying to read from stdin. Here I simulate a process that slowly outputs data to stdout:
steve@runes:~$ cat out.py import time print "Hello..." time.sleep(10) print "World!" time.sleep(10) print "Goodbye!" and another process that reads from stdin: steve@runes:~$ cat slurp.py import sys import time for line in sys.stdin: print time.ctime(), line When I pipe one to the other, I expect each line to be printed as they arrive, but instead they all queue up and happen at once: steve@runes:~$ python out.py | python slurp.py Wed Aug 27 15:13:44 2014 Hello... Wed Aug 27 15:13:44 2014 World! Wed Aug 27 15:13:44 2014 Goodbye! (Note how the time stamps are all together, instead of ten seconds apart.) Why is this happening? How can I read from sys.stdin "on the fly", so to speak, without waiting for the first process to end? Is there established terminology for talking about this sort of thing? -- Steven -- https://mail.python.org/mailman/listinfo/python-list