Why doesn't asyncio.as_completed
cancel unfinished tasks if it timeout?
#99933
Labels
asyncio.as_completed
cancel unfinished tasks if it timeout?
#99933
NewUserHa commentedDec 1, 2022
Feature or enhancement
asyncio.as_completed
should cancel unfinished tasks if it timeout, or even maybe have the ability to cancel no needed taskPitch
cpython/Lib/asyncio/tasks.py
Lines 588 to 609 in 0563be2
Why doesn't
asyncio.as_completed
cancel unfinished tasks if it timeout?Maybe say there may be many network requests pending, since that already raised exception then future requests should probably be canceled to save resources.
Probably because the
concurrent.futures.as_complete
didn't cancel unfinished tasks? But it's local resources than asyncio is usually network resources.More, I know the
asyncio.wait()
can do cancel the pending job. Butasyncio.as_complete()
probably should also be able to cancel the next coros if got the wanted result. But currently, the returned is a coroutine that can't cancel.The text was updated successfully, but these errors were encountered: