summaryrefslogtreecommitdiffstats
path: root/Lib/selectors.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-21 16:49:41 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-01-21 16:49:41 (GMT)
commit7067b5d92770569dcadb7c637517c5fc242339c5 (patch)
tree172c2c8c0c797b521160d5959e0914bf693439f8 /Lib/selectors.py
parent781a5441aeedb5acbfcd74d52583b1403f2b42f3 (diff)
downloadcpython-7067b5d92770569dcadb7c637517c5fc242339c5.zip
cpython-7067b5d92770569dcadb7c637517c5fc242339c5.tar.gz
cpython-7067b5d92770569dcadb7c637517c5fc242339c5.tar.bz2
selectors: add a comment to explain why and how poll timeout is rounded
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r--Lib/selectors.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index 63392f5..f8b56cd 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -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)