[Python-checkins] cpython: Issue #20311: EpollSelector now also rounds the timeout towards zero, as
victor.stinner
python-checkins at python.org
Tue Jan 21 21:01:06 CET 2014
http://hg.python.org/cpython/rev/7ce7295393c2
changeset: 88614:7ce7295393c2
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jan 21 21:00:47 2014 +0100
summary:
Issue #20311: EpollSelector now also rounds the timeout towards zero, as
PollSelector.
This change is not really required in Python 3.4, since select.epoll.poll() now
rounds also correctly the timeout. But Guido van Rossum prefers to have exactly
the same selectors.py file in CPython and Tulip projects: "it's not harmful".
files:
Lib/selectors.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/selectors.py b/Lib/selectors.py
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -411,7 +411,14 @@
return key
def select(self, timeout=None):
- timeout = -1 if timeout is None else max(timeout, 0)
+ if timeout is None:
+ timeout = -1
+ elif timeout <= 0:
+ timeout = 0
+ else:
+ # epoll_wait() has a resolution of 1 millisecond, round away
+ # from zero to wait *at least* timeout seconds.
+ timeout = math.ceil(timeout * 1e3) * 1e-3
max_ev = len(self._fd_to_key)
ready = []
try:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list