From 2283c6312d652f1e52315c95d02f9e25a2c2f439 Mon Sep 17 00:00:00 2001 From: Martin Altmayer Date: Sat, 28 Jul 2018 16:02:50 +0100 Subject: [PATCH 1/3] bpo-34263 Cap timeout submitted to epoll/select etc. to one day. --- Lib/asyncio/base_events.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index dc0ca3f02b9bf6..a79e123e5113d9 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -63,6 +63,9 @@ _HAS_IPv6 = hasattr(socket, 'AF_INET6') +# Maximum timeout passed to select to avoid OS limitations +MAXIMUM_SELECT_TIMEOUT = 24 * 3600 + def _format_handle(handle): cb = handle._callback @@ -1702,7 +1705,7 @@ def _run_once(self): elif self._scheduled: # Compute the desired timeout. when = self._scheduled[0]._when - timeout = max(0, when - self.time()) + timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT) if self._debug and timeout != 0: t0 = self.time() From aa677d46bf27eeda2f5bfc20253851dccaabb38e Mon Sep 17 00:00:00 2001 From: Martin Altmayer Date: Sat, 28 Jul 2018 17:01:13 +0100 Subject: [PATCH 2/3] bpo-34263 Add news entry. --- .../next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst diff --git a/Misc/NEWS.d/next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst b/Misc/NEWS.d/next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst new file mode 100644 index 00000000000000..799463b5916350 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst @@ -0,0 +1,2 @@ +asyncio's event loop will not pass timeouts longer than one day to +epoll/select etc. From 92623d277af74e6b84aa7896a6ce620c4a2f2ed4 Mon Sep 17 00:00:00 2001 From: Martin Altmayer Date: Sat, 28 Jul 2018 17:21:43 +0100 Subject: [PATCH 3/3] bpo-34263 Remove now obsolete warning about maximum timeout. --- Doc/library/asyncio-eventloop.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 317f3fb85c5481..212ee2fcd308e8 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -173,10 +173,6 @@ Which clock is used depends on the (platform-specific) event loop implementation; ideally it is a monotonic clock. This will generally be a different clock than :func:`time.time`. -.. note:: - - Timeouts (relative *delay* or absolute *when*) should not exceed one day. - .. method:: AbstractEventLoop.call_later(delay, callback, *args, context=None)