Skip to content

Commit 172a81e

Browse files
miss-islington1st1
authored andcommitted
[3.7] bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532) (GH-8586)
1 parent 3e4b688 commit 172a81e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/asyncio/base_events.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363

6464
_HAS_IPv6 = hasattr(socket, 'AF_INET6')
6565

66+
# Maximum timeout passed to select to avoid OS limitations
67+
MAXIMUM_SELECT_TIMEOUT = 24 * 3600
68+
6669

6770
def _format_handle(handle):
6871
cb = handle._callback
@@ -1702,7 +1705,7 @@ def _run_once(self):
17021705
elif self._scheduled:
17031706
# Compute the desired timeout.
17041707
when = self._scheduled[0]._when
1705-
timeout = max(0, when - self.time())
1708+
timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT)
17061709

17071710
if self._debug and timeout != 0:
17081711
t0 = self.time()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
asyncio's event loop will not pass timeouts longer than one day to
2+
epoll/select etc.

0 commit comments

Comments
 (0)