New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we put callback here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
DefaultSelector
as automatically selected most efficient.InterruptedError
is handled by selector (and since python 3.5 byselect.select
, see PEP 475)Checklist
master
orpython-dual-support
branchtox
successfully in local environment