diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-26 10:16:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-26 10:16:12 (GMT) |
commit | 19d953682e86ad51b19313ddba8ddb2602d6efd3 (patch) | |
tree | 27bce6f383b4627eeccdf45516ef66b9426c484a /Lib/asyncio | |
parent | 2fb64a0687c36c22933bae38970daa3c9a1ee84f (diff) | |
download | cpython-19d953682e86ad51b19313ddba8ddb2602d6efd3.zip cpython-19d953682e86ad51b19313ddba8ddb2602d6efd3.tar.gz cpython-19d953682e86ad51b19313ddba8ddb2602d6efd3.tar.bz2 |
gh-95051: ensure that timeouts scheduled with `asyncio.Timeout` that have already expired are deliverered promptly (GH-95109) (GH-95216)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
(cherry picked from commit 0c6f898005099be189ee65bcfda659f5fc13b802)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/timeouts.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/asyncio/timeouts.py b/Lib/asyncio/timeouts.py index a892053..94d2553 100644 --- a/Lib/asyncio/timeouts.py +++ b/Lib/asyncio/timeouts.py @@ -52,10 +52,10 @@ class Timeout: self._timeout_handler = None else: loop = events.get_running_loop() - self._timeout_handler = loop.call_at( - when, - self._on_timeout, - ) + if when <= loop.time(): + self._timeout_handler = loop.call_soon(self._on_timeout) + else: + self._timeout_handler = loop.call_at(when, self._on_timeout) def expired(self) -> bool: """Is timeout expired during execution?""" |