[issue16853] add a Selector to the select module

Guido van Rossum report at bugs.python.org
Mon Jan 7 03:59:13 CET 2013


Guido van Rossum added the comment:

Maybe I should explain the need for SELECT_CONNECT more.  This is necessary so that on Windows the PollSelector can use WSAPoll().  The reason is that for async connect() calls, WSAPoll() doesn't return the FD as writable, just as having an exception.  I didn't write the code (Richard Oudkerk did), and I've never run it (no access to Windows), but the workaround for the problem with WSAPoll() is apparently quite complex:
http://code.google.com/p/tulip/source/browse/tulip/unix_events.py#236

The long and short of it is that portable code must use add_connector() and remove_connector() instead of add_writer() and remove_writer() for async connect() calls.  So these need to be mapped to something different in the selector world.  The right thing would seem to add a separate flag, SELECT_CONNECT, with a value distinct from SELECT_IN and SELECT_OUT.  But I didn't write the code for that -- I made a hackish change so that the selector code exports SELECT_CONNECT as an alias for SELECT_OUT.  I did write code for add_connector() and remove_connector() but these may have to be modified slightly again later once the selector code has SELECT_OUT != SELECT_CONNECT.

Please do try to understand this -- it would not be possible to support WSAPoll() at all without distinguishing between write and connect readyness.

Feel free to ping Richard Oudkerk (shibturn at gmail.com) for more information.

I don't *think* the problems are in my code, since both tests pass when the SelectSelector is used.

I can currently only test on OSX 10.7 (Mountain Lion); hopefully I have more platforms after tomorrow (my first day at the new job).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16853>
_______________________________________


More information about the Python-bugs-list mailing list