mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-41891: ensure asyncio.wait_for waits for task completion (GH-22461) (#23840)
(cherry picked from commit 17ef4319a3
)
Co-authored-by: Richard Kojedzinszky <rkojedzinszky@users.noreply.github.com>
Co-authored-by: Richard Kojedzinszky <rkojedzinszky@users.noreply.github.com>
This commit is contained in:
parent
14619924c3
commit
82dbfd5a04
3 changed files with 66 additions and 1 deletions
|
@ -471,7 +471,10 @@ async def wait_for(fut, timeout, *, loop=None):
|
|||
return fut.result()
|
||||
else:
|
||||
fut.remove_done_callback(cb)
|
||||
fut.cancel()
|
||||
# We must ensure that the task is not running
|
||||
# after wait_for() returns.
|
||||
# See https://bugs.python.org/issue32751
|
||||
await _cancel_and_wait(fut, loop=loop)
|
||||
raise
|
||||
|
||||
if fut.done():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue