Async Gather With Concurrency Limit
Run coroutines with a semaphore-limited gather for bounded concurrency in async data fetching pipelines.
Code
import asyncio
async def gather_limited(coros, limit=10):
sem = asyncio.Semaphore(limit)
async def with_sem(coro):
async with sem:
return await coro
return await asyncio.gather(*(with_sem(c) for c in coros))Report a problem with this exampleOpens a pre-filled issue on GitHub.