summaryrefslogtreecommitdiffstats
path: root/Lib/selectors.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-21 20:00:47 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-21 20:00:47 (GMT)
commit567b26e882a3a73f37f69390f3a34ec533ff4590 (patch)
tree2b538db1c2560d2cf14d9bdeaa9bb2990ec5252f /Lib/selectors.py
parent2d854c8e7b14d17d7b0d1508c193fe3db92dd215 (diff)
downloadcpython-567b26e882a3a73f37f69390f3a34ec533ff4590.zip
cpython-567b26e882a3a73f37f69390f3a34ec533ff4590.tar.gz
cpython-567b26e882a3a73f37f69390f3a34ec533ff4590.tar.bz2
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".
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r--Lib/selectors.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index f8b56cd..1bdf972 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -411,7 +411,14 @@ if hasattr(select, 'epoll'):
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: