mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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>
This commit is contained in:
parent
eb9c8a8bea
commit
0c6f898005
4 changed files with 32 additions and 4 deletions
|
@ -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?"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue