]> granicus.if.org Git - python/commitdiff
bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532)
authorMartinAltmayer <martin.altmayer@web.de>
Tue, 31 Jul 2018 14:06:12 +0000 (15:06 +0100)
committerYury Selivanov <yury@magic.io>
Tue, 31 Jul 2018 14:06:12 +0000 (10:06 -0400)
Doc/library/asyncio-eventloop.rst
Lib/asyncio/base_events.py
Misc/NEWS.d/next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst [new file with mode: 0644]

index cf7b6d88725e411f299825e31ff61ef8c9deb955..5b3d29dcaa467fd58d9db489b71a3ec3e3e28a44 100644 (file)
@@ -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)
 
index 75989a7641b8bbfd4e20848ae220dbad00da24e6..78fe2a719f92eb8b1055e208b017f21aebe01805 100644 (file)
@@ -63,6 +63,9 @@ _FATAL_ERROR_IGNORE = (BrokenPipeError,
 
 _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
@@ -1708,7 +1711,7 @@ class BaseEventLoop(events.AbstractEventLoop):
         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()
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 (file)
index 0000000..799463b
--- /dev/null
@@ -0,0 +1,2 @@
+asyncio's event loop will not pass timeouts longer than one day to
+epoll/select etc.