summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/selectors.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py
index f8b56cd..1bdf972 100644
--- a/Lib/selectors.py
+++ b/Lib/selectors.py
@@ -411,7 +411,14 @@ if hasattr(select, 'epoll'):
return key
def select(self, timeout=None):
- timeout = -1 if timeout is None else max(timeout, 0)
+ if timeout is None:
+ timeout = -1
+ elif timeout <= 0:
+ timeout = 0
+ else:
+ # epoll_wait() has a resolution of 1 millisecond, round away
+ # from zero to wait *at least* timeout seconds.
+ timeout = math.ceil(timeout * 1e3) * 1e-3
max_ev = len(self._fd_to_key)
ready = []
try: