asyncio.gather is a Python asyncio pattern for processing independent awaitable tasks concurrently and collecting their results together. It can shorten task-loop runtime compared with sequential processing. section 9.5 section 9.6
Use it when work items do not depend on one another. Keep sequential processing when tasks share ordering or state, and check rate limits before increasing concurrency. section 9.6
A practical decision checklist:
- Confirm that each item can run independently. section 9.6
- Compare parallel and sequential completion time rather than assuming a fixed speedup. section 9.5
- Watch rate limits and preserve explicit tracking of completed, failed, and pending items. section 9.6
Parallel task processing
An exercise copies a retrying task loop, applies the asyncio.gather parallel pattern with batch_size=3, then compares total execution time and completion rates with the sequential version. section 9.5


