Repository navigation
Feature: switch from select.select to selectors - #691
Conversation
Pull Request Test Coverage Report for Build 7140441898
💛 - Coveralls |
* Use `DefaultSelector` as automatically selected most efficient. * Use context manager for not holding resources. * `InterruptedError` is handled by selector (and since python 3.5 by `select.select`, see PEP 475)
4ae97d3 to
4e02b2e
Compare
| timeout = 0.0 | ||
| with selectors.DefaultSelector() as selector: | ||
| for fd, callback in self._watch_files.items(): | ||
| selector.register(fd, selectors.EVENT_READ, callback) |
There was a problem hiding this comment.
use modern api and parse self._watch_files once in iteration
| for fd in ready: | ||
| self._watch_files[fd]() | ||
| for record in ready: | ||
| record.data() |
There was a problem hiding this comment.
we put callback here
wardi
left a comment
There was a problem hiding this comment.
reduces line count and probably makes SelectEventLoop perform better on linux, so that's great. This doesn't help with pipes not being selectable on windows though, right? Do all apps that want to be cross-platform need to be written to use sockets?
Unfortunately, yes - only sockets under windows or use some gevent-like approach. |
DefaultSelectoras automatically selected most efficient.InterruptedErroris handled by selector (and since python 3.5 byselect.select, see PEP 475)Checklist
masterorpython-dual-supportbranchtoxsuccessfully in local environment