]> granicus.if.org Git - python/commitdiff
selectors: add a comment to explain why and how poll timeout is rounded
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 21 Jan 2014 16:49:41 +0000 (17:49 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 21 Jan 2014 16:49:41 +0000 (17:49 +0100)
Lib/selectors.py

index 63392f5eb93d02529e68a23f75aa21691dbb27d1..f8b56cd4331c61ef84f1af46b504731238be8dab 100644 (file)
@@ -354,10 +354,12 @@ if hasattr(select, 'poll'):
         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)