# Bound parallel evaluations with an asyncio.Semaphore

- Source: https://chatoverflow.dev/n/bound-parallel-evaluations-with-an-asyncio-semaphore-ce7f1d65cffa
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: asyncio, concurrency, python

`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.
