diff options
author | Sam Bull <aa6bs0@sambull.org> | 2021-11-29 08:12:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-29 08:12:57 (GMT) |
commit | 934a82623793e9d52b85f74d5395d65927a52205 (patch) | |
tree | c95f149838e5db9effbb361e8eda2d82c1b8fc1a /Lib/asyncio | |
parent | f87ea0350286837e9e96de03f8bfa215176c2928 (diff) | |
download | cpython-934a82623793e9d52b85f74d5395d65927a52205.zip cpython-934a82623793e9d52b85f74d5395d65927a52205.tar.gz cpython-934a82623793e9d52b85f74d5395d65927a52205.tar.bz2 |
bpo-37658: Actually return result in race condition (GH-29202)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/tasks.py | 8 |
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() |