diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-12-18 19:19:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 19:19:10 (GMT) |
commit | 82dbfd5a04863d8b6363527e6a34a90c9aa5691b (patch) | |
tree | 9af5aae82bc1062485aa058ab1e3a012fecc4629 /Lib/asyncio/tasks.py | |
parent | 14619924c36435e356135988c244cbc28652c82b (diff) | |
download | cpython-82dbfd5a04863d8b6363527e6a34a90c9aa5691b.zip cpython-82dbfd5a04863d8b6363527e6a34a90c9aa5691b.tar.gz cpython-82dbfd5a04863d8b6363527e6a34a90c9aa5691b.tar.bz2 |
bpo-41891: ensure asyncio.wait_for waits for task completion (GH-22461) (#23840)
(cherry picked from commit 17ef4319a34f5a2f95e7823dfb5f5b8cff11882d)
Co-authored-by: Richard Kojedzinszky <rkojedzinszky@users.noreply.github.com>
Co-authored-by: Richard Kojedzinszky <rkojedzinszky@users.noreply.github.com>
Diffstat (limited to 'Lib/asyncio/tasks.py')
-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 f486b67..d6262ae 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -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(): |