diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-12-18 17:45:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 17:45:24 (GMT) |
commit | a3dec9d8ec5ae142946ff6b94947a183d7c48f35 (patch) | |
tree | c479bf0aa75865321814db864a96658d63c8fce2 /Lib/asyncio | |
parent | 12032cdec5ae1e56d4e4b8206fb2e9cccc5a9f58 (diff) | |
download | cpython-a3dec9d8ec5ae142946ff6b94947a183d7c48f35.zip cpython-a3dec9d8ec5ae142946ff6b94947a183d7c48f35.tar.gz cpython-a3dec9d8ec5ae142946ff6b94947a183d7c48f35.tar.bz2 |
bpo-41891: ensure asyncio.wait_for waits for task completion (GH-22461)
(cherry picked from commit 17ef4319a34f5a2f95e7823dfb5f5b8cff11882d)
Co-authored-by: Richard Kojedzinszky <rkojedzinszky@users.noreply.github.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/tasks.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index 1fa76a1..7094132 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -484,7 +484,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(): |