timeout with read operations

P at draigBrady.com P at draigBrady.com
Thu Jul 22 12:01:13 CEST 2004


Jim wrote:
> 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?

I don't think anything could happen
that would cause a block. That's the
assumption I made when implementing:
http://www.pixelbeat.org/libs/subProcess.py

If you find this is not the case you can
always make the fileno non blocking but
I really don't think this is required.

Pádraig.



More information about the Python-list mailing list