summaryrefslogtreecommitdiffstats
path: root/Lib/selectors.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-21 00:48:28 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-21 00:48:28 (GMT)
commit11da8e24ba1090b9d55f3451345f0724055f125f (patch)
tree37f6cbbf807c8b44934990b25c13fe05055431b6 /Lib/selectors.py
parent09354fd606409aea1270474270eb8a9396bb477e (diff)
downloadcpython-11da8e24ba1090b9d55f3451345f0724055f125f.zip
cpython-11da8e24ba1090b9d55f3451345f0724055f125f.tar.gz
cpython-11da8e24ba1090b9d55f3451345f0724055f125f.tar.bz2
Issue #20311: selector.PollSelector.select() now rounds the timeout away from
zero, instead of rounding towards zero. For example, a timeout of one microsecond is now rounded to one millisecond, instead of being rounded to zero. Move also a test in test_epoll which was moved by my previous merge.
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r--Lib/selectors.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index a44d5e9..63392f5 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -8,6 +8,7 @@ This module allows high-level and efficient I/O multiplexing, built upon the
from abc import ABCMeta, abstractmethod
from collections import namedtuple, Mapping
import functools
+import math
import select
import sys
@@ -351,7 +352,12 @@ if hasattr(select, 'poll'):
return key
def select(self, timeout=None):
- timeout = None if timeout is None else max(int(1000 * timeout), 0)
+ if timeout is None:
+ timeout = None
+ elif timeout < 0:
+ timeout = 0
+ else:
+ timeout = int(math.ceil(timeout * 1000.0))
ready = []
try:
fd_event_list = self._poll.poll(timeout)