STINNER Victor added the comment: 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. ---------- _______________________________________ 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