summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/tasks.py
diff options
context:
space:
mode:
authorRichard Kojedzinszky <rkojedzinszky@users.noreply.github.com>2020-12-18 17:26:04 (GMT)
committerGitHub <noreply@github.com>2020-12-18 17:26:04 (GMT)
commit17ef4319a34f5a2f95e7823dfb5f5b8cff11882d (patch)
tree769a121c883be857a22432fc1b5c57b80e60dd6a /Lib/asyncio/tasks.py
parent2179349d8cf45b1202775547df384b1fde31630a (diff)
downloadcpython-17ef4319a34f5a2f95e7823dfb5f5b8cff11882d.zip
cpython-17ef4319a34f5a2f95e7823dfb5f5b8cff11882d.tar.gz
cpython-17ef4319a34f5a2f95e7823dfb5f5b8cff11882d.tar.bz2
bpo-41891: ensure asyncio.wait_for waits for task completion (#22461)
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r--Lib/asyncio/tasks.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 0d3a24b..52f1e66 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -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():