select.select and socket.setblocking

Jean-Paul Calderone exarkun at divmod.com
Tue Dec 30 14:27:16 EST 2008


On Tue, 30 Dec 2008 19:19:08 +0100, Francesco Bochicchio <bockman at virgilio.it> wrote:
> [snip]
>
>If you are interested in socket errors, you should
>also fill the third 'fd-set' in the select call, and after select returns 
>check that fd is not in it anymore:
>
>ready = select.select( [fd],[], [fd] )
>if fd in ready[2]:
>    # raise your error here

The third argument to select() isn't for monitoring sockets for errors.  Its
behavior is also rather platform sensitive.  In general, you don't need it
at all on POSIX, but on Windows you should pass the same list for it as you
pass for the write-set, merge the results, and treat them all as writeable.

Or use a higher-level library that deals with all the asinine details for
you. ;)

Jean-Paul



More information about the Python-list mailing list