summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/tasks.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-11-29 08:37:34 (GMT)
committerGitHub <noreply@github.com>2021-11-29 08:37:34 (GMT)
commit305236e03a274850be8ed399ea3390ee71519ef4 (patch)
tree13a7127844ffa458aebe69aa3eb6deb0471575a1 /Lib/asyncio/tasks.py
parent8d1a5800645575ec876932bbb9aed3aa65d18f46 (diff)
downloadcpython-305236e03a274850be8ed399ea3390ee71519ef4.zip
cpython-305236e03a274850be8ed399ea3390ee71519ef4.tar.gz
cpython-305236e03a274850be8ed399ea3390ee71519ef4.tar.bz2
bpo-37658: Actually return result in race condition (GH-29202)
(cherry picked from commit 934a82623793e9d52b85f74d5395d65927a52205) Co-authored-by: Sam Bull <aa6bs0@sambull.org>
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r--Lib/asyncio/tasks.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 9a9d0d6..53eef84 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -415,11 +415,9 @@ async def wait_for(fut, timeout):
await _cancel_and_wait(fut, loop=loop)
try:
- fut.result()
+ return fut.result()
except exceptions.CancelledError as exc:
raise exceptions.TimeoutError() from exc
- else:
- raise exceptions.TimeoutError()
waiter = loop.create_future()
timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
@@ -455,11 +453,9 @@ async def wait_for(fut, timeout):
# exception, we should re-raise it
# See https://bugs.python.org/issue40607
try:
- fut.result()
+ return fut.result()
except exceptions.CancelledError as exc:
raise exceptions.TimeoutError() from exc
- else:
- raise exceptions.TimeoutError()
finally:
timeout_handle.cancel()