with timeout(...):

Nick Craig-Wood nick at craig-wood.com
Sat Mar 31 11:30:04 CEST 2007

Hendrik van Rooyen <mail at microcorp.co.za> wrote:
>   "Nick Craig-Wood" <n...k at cra..od.com> wrote:
> > I'd like there to be something which works well enough for day to day
> > use.  Ie doesn't ever wreck the internals of python.  It could have
> > some caveats like "may not timeout during C functions which haven't
> > released the GIL" and that would still make it very useable.
>  I second this (or third or whatever if my post is slow).
>  It is tremendously useful to start something and to be told it has timed
>  out by a call, rather than to have to unblock the i/o yourself and
>  to "busy-loop" to see if its successful.

Yes, exactly!

>  And from what I can see the select functionality is not much
>  different from busy looping...

Conceptually it is no different.  In practice your process goes to
sleep until the OS wakes it up again with more data so it is much more
CPU efficient (and possibly lower latency) than busy waiting.

Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick

More information about the Python-list mailing list