Skip to content

Commit 944451c

Browse files
MartinAltmayer1st1
authored andcommitted
bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532)
1 parent 9c18b1a commit 944451c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ Which clock is used depends on the (platform-specific) event loop
173173
implementation; ideally it is a monotonic clock. This will generally be
174174
a different clock than :func:`time.time`.
175175

176-
.. note::
177-
178-
Timeouts (relative *delay* or absolute *when*) should not exceed one day.
179-
180176

181177
.. method:: AbstractEventLoop.call_later(delay, callback, *args, context=None)
182178

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
@@ -1708,7 +1711,7 @@ def _run_once(self):
17081711
elif self._scheduled:
17091712
# Compute the desired timeout.
17101713
when = self._scheduled[0]._when
1711-
timeout = max(0, when - self.time())
1714+
timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT)
17121715

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