diff options
author | 2018-07-31 15:06:12 +0100 | |
---|---|---|
committer | 2018-07-31 10:06:12 -0400 | |
commit | 944451cd8d3e897138f4b43569de13cd081ee251 (patch) | |
tree | 07230ba80372c8efb6da78ac994934ad73167291 /Lib/asyncio/base_events.py | |
parent | bpo-33089: Add math.dist() for computing the Euclidean distance between two p... (diff) | |
download | cpython-944451cd8d3e897138f4b43569de13cd081ee251.tar.gz cpython-944451cd8d3e897138f4b43569de13cd081ee251.tar.bz2 cpython-944451cd8d3e897138f4b43569de13cd081ee251.zip |
bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532)
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r-- | Lib/asyncio/base_events.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 75989a7641b..78fe2a719f9 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -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() |