Skip to content

Commit c8a7b00

Browse files
committed
bpo-41891: ensure asyncio.wait_for waits for task completion
1 parent 17b5be0 commit c8a7b00

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/asyncio/tasks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,10 @@ async def wait_for(fut, timeout, *, loop=None):
469469
return fut.result()
470470
else:
471471
fut.remove_done_callback(cb)
472-
fut.cancel()
472+
# We must ensure that the task is not running
473+
# after wait_for() returns.
474+
# See https://bugs.python.org/issue32751
475+
await _cancel_and_wait(fut, loop=loop)
473476
raise
474477

475478
if fut.done():
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure asyncio.wait_for waits for task completion

0 commit comments

Comments
 (0)