From Dev.to
Limiting concurrency in Python asyncio with a semaphore and per-task timeouts, in the right order
asyncio.gather(*(call(x) for x in items)) starts every call at once: with a thousand prompts, that's a thousand simultaneous requests to an LLM API, and an immediate wall of 429s. Cap it with asyncio....
