timeout with read operations
mynews44 at yahoo.com
Thu Jul 22 19:46:03 CEST 2004
jim_8421 at hotmail.com (Jim) wrote in message news:<c5694ea3.0407211519.62a56f1a at posting.google.com>...
> 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 == [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.
Could you not use signals to do what you need?
Someone just pointed me in that direction, and it worked great for
me. About 5 lines of code.
Check the example out.
I hope I have helped! I am usually the n00b asking the questions
More information about the Python-list