Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a700725

Browse files
committed
Cancel the inner task
1 parent b196632 commit a700725

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Lib/asyncio/tasks.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,11 @@ async def wait_for(fut, timeout):
444444
This function is a coroutine.
445445
"""
446446

447-
if not futures.isfuture(fut):
448-
# wrap a coroutine
449-
fut = create_task(fut)
447+
async def inner():
448+
async with timeouts.timeout(timeout):
449+
return await fut
450450

451-
async with timeouts.timeout(timeout):
452-
return await fut
451+
return await create_task(inner())
453452

454453

455454
async def _wait(fs, timeout, return_when, loop):

0 commit comments

Comments
 (0)