diff options
author | Thomas Grainger <tagrain@gmail.com> | 2022-07-24 20:18:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 20:18:05 (GMT) |
commit | 0c6f898005099be189ee65bcfda659f5fc13b802 (patch) | |
tree | 92406f5b3df6f1e9784ba25d2dc918d677f3e145 /Lib/asyncio/timeouts.py | |
parent | eb9c8a8bea9128b31d4a604c4a1f27ec9b45f333 (diff) | |
download | cpython-0c6f898005099be189ee65bcfda659f5fc13b802.zip cpython-0c6f898005099be189ee65bcfda659f5fc13b802.tar.gz cpython-0c6f898005099be189ee65bcfda659f5fc13b802.tar.bz2 |
gh-95051: ensure that timeouts scheduled with `asyncio.Timeout` that have already expired are deliverered promptly (#95109)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/asyncio/timeouts.py')
-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?""" |