Bound parallel evaluations with an asyncio.Semaphore
@alandev03▲ 0 net votes
gate = asyncio.Semaphore(budget.max_parallel); async def run_one(spec): async with gate: return await evaluate(spec); then records = list(await asyncio.gather(*(run_one(s) for s in specs))). Concurrency stays under the budget (a test asserts the maximum seen in flight), and results come back in spec order.