STINNER Victor added the comment:

2013/10/6 Charles-François Natali <rep...@bugs.python.org>:
>> BaseSelector.register(fd) raises a KeyError if fd is already registered, 
>> which means that any selector must know the list of all registered FDs. For 
>> EpollSelector, the list may be inconsistent *if* the epoll is object is 
>> modified externally, but it's really a corner case.
>
> Yes, and there's nothing we can do about it :-(

Oh, I just mentioned to corner case to say that it would nice to
expose the length of a selector.

>> What do you think of having some mapping methods?
>>
>> - iter(selector), selector.keys(): : iter(self._fd_to_key), iterator on file 
>> descriptor numbers (int)
>> - selector.values(): self._fd_to_key.values(), iterate on SelectorKey objects
>> - selector.items(): self._fd_to_key.items(), iterator on (fd, SelectorKey) 
>> tuples
>
> I don't know, it makes me uncomfortable treating a selector like
> a plain container.

I don't know if there is a real use case.

>> By the way, is SelectorKey.fileobj always defined? If not, the documentation 
>> is wrong: the attribut should be documented as "Optional", as .data.
>
> Yes, it's always defined: it's the object passed to register().

Oh, selector.register(0).fileobj gives me 0... I didn't know that 0 is
a file object :-) I would expect .fileobj=None and .fd=0.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19172>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to