[Python-checkins] cpython: selectors: add a comment to explain why and how poll timeout is rounded
victor.stinner
python-checkins at python.org
Tue Jan 21 17:49:58 CET 2014
http://hg.python.org/cpython/rev/b81293d895d6
changeset: 88607:b81293d895d6
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jan 21 17:49:41 2014 +0100
summary:
selectors: add a comment to explain why and how poll timeout is rounded
files:
Lib/selectors.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Lib/selectors.py b/Lib/selectors.py
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -354,10 +354,12 @@
def select(self, timeout=None):
if timeout is None:
timeout = None
- elif timeout < 0:
+ elif timeout <= 0:
timeout = 0
else:
- timeout = int(math.ceil(timeout * 1000.0))
+ # poll() has a resolution of 1 millisecond, round away from
+ # zero to wait *at least* timeout seconds.
+ timeout = int(math.ceil(timeout * 1e3))
ready = []
try:
fd_event_list = self._poll.poll(timeout)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list