Skip to content

bpo-34263 Cap timeout submitted to epoll/select etc. to one day. #8532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@

_HAS_IPv6 = hasattr(socket, 'AF_INET6')

# Maximum timeout passed to select to avoid OS limitations
MAXIMUM_SELECT_TIMEOUT = 24 * 3600
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, maybe it's better to make the constant private. What do you think @1st1?



def _format_handle(handle):
cb = handle._callback
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
asyncio's event loop will not pass timeouts longer than one day to
epoll/select etc.