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.
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 @@
from abc import ABCMeta, abstractmethod
from collections import namedtuple, Mapping
import functools
+import math
import select
import sys
@@ -351,7 +352,12 @@
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)