Bug report
Bug description:
wait_for() with a non-positive timeout does not register an awaited-by edge on the future it waits on
Repro:
import asyncio
async def worker():
try:
await asyncio.sleep(10)
finally:
await asyncio.sleep(10)
async def probe(t):
await asyncio.wait_for(t, 0)
async def main():
t = asyncio.ensure_future(worker())
p = asyncio.create_task(probe(t))
await asyncio.sleep(0.1)
print(asyncio.format_call_graph(t))
p.cancel()
t.cancel()
asyncio.run(main())
Actual:
* Task(name='Task-2', id=0x102cb8b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/tasks.py', line 707, in async sleep()
| File '/Users/timofeiivankov/cpython/repro.py', line 7, in async worker()
Expected:
* Task(name='Task-2', id=0x101c0cb90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/tasks.py', line 714, in async sleep()
| File '/Users/timofeiivankov/cpython/repro.py', line 7, in async worker()
+ Awaited by:
* Task(name='Task-3', id=0x1019890a0)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/tasks.py', line 553, in async _cancel_and_wait()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/tasks.py', line 479, in async wait_for()
| File '/Users/timofeiivankov/cpython/repro.py', line 10, in async probe()
Proposed fix: register the edge in _cancel_and_wait()
I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
wait_for()with a non-positive timeout does not register an awaited-by edge on the future it waits onRepro:
Actual:
Expected:
Proposed fix: register the edge in
_cancel_and_wait()I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs