[issue16853] add a Selector to the select module

Charles-François Natali report at bugs.python.org
Fri Aug 2 17:16:53 CEST 2013


Charles-François Natali added the comment:

Here's a patch, based on the version in tulip's repo.
I've added doc update and tests.

I also made the following changes:
- BaseSelector is an abstract base class (so one could imagine user code implementing its own selector on top of it)
- SelectorKey is a named tuple: I think that's better than a class, because SelectorKeys can be returned to the user (register(), get_info(), etc), and we don't want him to mess with them. Also, we get a nice repr() for free
- since SelectorKey is immutable, I added a get_keys() method, which returns all the keys registered. Since it's a dict values, the user can't mess with it

This get_keys() method superseedes the registered_count() method, which can be simply replaced with len(selector.get_keys()). We could probably remove it? It also sort of superseedes the get_info() method: I don't remember, why was it needed?

Would it be possible to get it into 3.4?

----------
keywords: +needs review
Added file: http://bugs.python.org/file31116/selector-9.diff

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


More information about the Python-bugs-list mailing list