mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-32751: Wait for task cancel in asyncio.wait_for() when timeout <= 0 (GH-21895) (GH-21963)
When I was fixing bpo-32751 back in GH-7216 I missed the case when
*timeout* is zero or negative. This takes care of that.
Props to @aaliddell for noticing the inconsistency.
(cherry picked from commit c517fc7121
)
Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
This commit is contained in:
parent
d7cd1164c1
commit
1036ccb55d
3 changed files with 41 additions and 2 deletions
|
@ -445,8 +445,13 @@ async def wait_for(fut, timeout, *, loop=None):
|
|||
if fut.done():
|
||||
return fut.result()
|
||||
|
||||
fut.cancel()
|
||||
raise exceptions.TimeoutError()
|
||||
await _cancel_and_wait(fut, loop=loop)
|
||||
try:
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue