asyncio.gather with a timeout: a deadline for the whole batch without losing the results that finished
To give a whole batch of asyncio calls one deadline , don't wrap gather in wait_for : when time runs out you get a TimeoutError and lose every result, including the ones that had already finished . Use asyncio.wait(tasks, timeout=...) instead. It returns the finished and unfinished tasks as two set…
Read the full story at DEV Community — AI ↗
Timeline · 1 report
- 2026-12-03 17:52 · DEV Community — AI
asyncio.gather with a timeout: a deadline for the whole batch without losing the results that finished