bpo-41891: ensure asyncio.wait_for waits for task completion (#22461)

This commit is contained in:
Richard Kojedzinszky 2020-12-18 18:26:04 +01:00 committed by GitHub
parent 2179349d8c
commit 17ef4319a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 1 deletions

View file

@ -437,7 +437,10 @@ async def wait_for(fut, timeout):
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():