Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 567b26e

Browse files
committed
Issue #20311: EpollSelector now also rounds the timeout towards zero, as
PollSelector. This change is not really required in Python 3.4, since select.epoll.poll() now rounds also correctly the timeout. But Guido van Rossum prefers to have exactly the same selectors.py file in CPython and Tulip projects: "it's not harmful".
1 parent 2d854c8 commit 567b26e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/selectors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,14 @@ def unregister(self, fileobj):
411411
return key
412412

413413
def select(self, timeout=None):
414-
timeout = -1 if timeout is None else max(timeout, 0)
414+
if timeout is None:
415+
timeout = -1
416+
elif timeout <= 0:
417+
timeout = 0
418+
else:
419+
# epoll_wait() has a resolution of 1 millisecond, round away
420+
# from zero to wait *at least* timeout seconds.
421+
timeout = math.ceil(timeout * 1e3) * 1e-3
415422
max_ev = len(self._fd_to_key)
416423
ready = []
417424
try:

0 commit comments

Comments
 (0)