timeout with read operations

Jim jim_8421 at hotmail.com
Thu Jul 22 01:19:19 CEST 2004


Hi,

I am trying to figure out a way to implement a timeout along with a
read() call on an open file.  It only has to work on linux,
for now I am trying:

ret = select.select( [fileno],[],[], timeout )
if ret[0] == [fileno]
    # do read

but .. what if between the select and read call something happens and
the read blocks indefinitly?
Is there a way I can have a functions like file.read( timeout ), where
timeout out is a gauranteed lower bound?  I know that there is for
sockets, with the settimeout function, but I don't know how they
implemented it.



More information about the Python-list mailing list