My problem is:
select
indicates that there is data to be read, I want to read whatever is there, I do not want to wait for a max
amount to be p
In os
module there is os.read function that allows lower level control over reading from file descriptor. It is nonblocking as long as there is at least a byte ready to read.
os.read(fd, n)
Read at most n bytes from file descriptor fd. Return a string containing the bytes read. If the end of the file referred to by fd has been reached, an empty string is returned.
Availability: Unix, Windows.
Note: This function is intended for low-level I/O and must be applied to a file descriptor as returned by
os.open()
orpipe()
. To read a “file object” returned by the built-in functionopen()
or bypopen()
orfdopen()
, orsys.stdin
, use itsread()
orreadline()
methods.