Blocking read on pipes
Arnau Sánchez
arnau at gbt.tfo.upm.es
Thu Jul 15 18:33:42 EDT 2004
Hello,
I have a problem when reading from stdin (using it as pipe) in a Python program (the sender
is written in C):
C (sender)
write(1, buffer, 4)
Python (recv.py)
sys.stdin.read(256) or sys.stdin.read()
sender | recv.py
Python's read blocks the program because the written buffer length (4) is lower than the indicated
in read function (256), but when I do the same with C (read(0, buffer, 256)) it is not blocking,
just
returns the four bytes. That is what I need.
I've tried to flush the stdout in the sending program, but it does the same.
any ideas?
thanks,
arnau
More information about the Python-list
mailing list