This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients christian.heimes, felipecruz, giampaolo.rodola, gvanrossum, neologix, pitrou, rosslagerwall
Date 2013-01-05.20:23:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
> I think that this needs extensive tests that verify the behavior of many end cases, including under duress (e.g. when there are too many connections for the kernel to handle).  That would seem the only way to make sure that the code is reliable across platforms.  It is likely that you could borrow some ideas for test scenarios from Twisted.

Will do.

I'm adding a new version taking into account some of Giampaolo's remarks.

Also, the API now also allows passing a file descriptor or any object
with a `fileno()` method, since it will likely be useful.

To sum up, the API is:

    def register(self, fileobj, events, data=None):
        """Register a file object.

        fileobj -- file object
        events  -- events to monitor (bitwise mask of SELECT_IN|SELECT_OUT)
        data    -- attached data

    def unregister(self, fileobj):
        """Unregister a file object.

        fileobj -- file object

    def modify(self, fileobj, events, data=None):
        """Change a registered file object monitored events or attached data.

        fileobj -- file object
        events  -- events to monitor (bitwise mask of SELECT_IN|SELECT_OUT)
        data    -- attached data

    def select(self, timeout=None):
        """Perform the actual selection, until some monitored file objects are
        ready or a timeout expires.

        timeout -- if timeout > 0, this specifies the maximum wait time, in
                   if timeout == 0, the select() call won't block, and will
                   report the currently ready file objects
                   if timeout is None, select() will block until a monitored
                   file object becomes ready

        list of (fileobj, events, attached data) for ready file objects
        `events` is a bitwise mask of SELECT_IN|SELECT_OUT output looks a lot like poll()/epoll() except for
two details: the output is the file object, and not the file
descriptor (poll()/epoll() are unfortunately inconsistent in this
regard), and there's a third field, the attached data (will be None if
not provided in register()/modify()). I think that this optional field
is really useful to pass e.g. a callback or some context information.
File name Uploaded
selector-5.diff neologix, 2013-01-05.20:23:26
Date User Action Args
2013-01-05 20:23:27neologixsetrecipients: + neologix, gvanrossum, pitrou, giampaolo.rodola, christian.heimes, rosslagerwall, felipecruz
2013-01-05 20:23:27neologixlinkissue16853 messages
2013-01-05 20:23:27neologixcreate