unbuffered read from stdin in python
问题 I'm writing a python script that can read input through a pipe from another command like so batch_job | myparser My script myparser processes the output of batch_job and write to its own stdout. My problem is that I want to see the output immediately (the output of batch_job is processed line-by-line) but there appears to be this notorious stdin buffering (allegedly 4KB, I haven't verified) which delays everything. The problem has been discussed already here here and here. I tried the