mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-37658: Fix asyncio.wait_for() to respect waited task status (GH-21894) (GH-21964)
Currently, if `asyncio.wait_for()` itself is cancelled it will always
raise `CancelledError` regardless if the underlying task is still
running. This is similar to a race with the timeout, which is handled
already.
(cherry picked from commit a2118a1462
)
Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
This commit is contained in:
parent
1036ccb55d
commit
9de6be4e2a
3 changed files with 24 additions and 3 deletions
|
@ -465,9 +465,12 @@ async def wait_for(fut, timeout, *, loop=None):
|
|||
try:
|
||||
await waiter
|
||||
except exceptions.CancelledError:
|
||||
fut.remove_done_callback(cb)
|
||||
fut.cancel()
|
||||
raise
|
||||
if fut.done():
|
||||
return fut.result()
|
||||
else:
|
||||
fut.remove_done_callback(cb)
|
||||
fut.cancel()
|
||||
raise
|
||||
|
||||
if fut.done():
|
||||
return fut.result()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue