Skip to content

Commit 6f16ffc

Browse files
miss-islington1st1
authored andcommitted
[3.6] bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532) (GH-8587)
1 parent ada5d99 commit 6f16ffc

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
@@ -56,6 +56,9 @@
5656

5757
_HAS_IPv6 = hasattr(socket, 'AF_INET6')
5858

59+
# Maximum timeout passed to select to avoid OS limitations
60+
MAXIMUM_SELECT_TIMEOUT = 24 * 3600
61+
5962

6063
def _format_handle(handle):
6164
cb = handle._callback
@@ -1378,7 +1381,7 @@ def _run_once(self):
13781381
elif self._scheduled:
13791382
# Compute the desired timeout.
13801383
when = self._scheduled[0]._when
1381-
timeout = max(0, when - self.time())
1384+
timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT)
13821385

13831386
if self._debug and timeout != 0:
13841387
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)