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 vstinner
Recipients neologix, pitrou, vstinner
Date 2013-10-06.07:19:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1381043959.76.0.969700974602.issue19172@psf.upfronthosting.co.za>
In-reply-to
Content
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.

"while selector: ..." is a nice (common?) pattern, it is used by subprocess.communicate() at least.

> I'm not sure whether selectors have a natural length

len(self._fd_to_key) is the natural length. bool(selector) uses selector.__length__() is defined, right?


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

"SelectorKey" name is confusing, it's not really a key as a dictionary dict. SelectorKey.fd *is* the key, Selector.event is not.

"SelectorFile" or "SelectorItem" would be more explicit, no?

By the way, is SelectorKey.fileobj always defined? If not, the documentation is wrong: the attribut should be documented as "Optional", as .data.
History
Date User Action Args
2013-10-06 07:19:19vstinnersetrecipients: + vstinner, pitrou, neologix
2013-10-06 07:19:19vstinnersetmessageid: <1381043959.76.0.969700974602.issue19172@psf.upfronthosting.co.za>
2013-10-06 07:19:19vstinnerlinkissue19172 messages
2013-10-06 07:19:19vstinnercreate