[3.6] bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532) (GH-8587)

https://github.com/python/cpython/commit/6f16ffc1879fc934eba297b3e81bd940e32... commit: 6f16ffc1879fc934eba297b3e81bd940e32a7e03 branch: 3.6 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: Yury Selivanov <yury@magic.io> date: 2018-07-31T11:28:56-04:00 summary: [3.6] bpo-34263 Cap timeout submitted to epoll/select etc. to one day. (GH-8532) (GH-8587) files: A Misc/NEWS.d/next/Library/2018-07-28-17-00-36.bpo-34263.zUfRsu.rst M Lib/asyncio/base_events.py diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 79f0d63c5726..30ac5924d06b 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -56,6 +56,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 @@ -1378,7 +1381,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() 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 000000000000..799463b59163 --- /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.
participants (1)
-
Yury Selivanov