Olve Heitmann
10/03/2025, 9:36 PMMarvin
10/03/2025, 9:37 PMMarvin
10/03/2025, 9:40 PM@task). Pure asyncio coroutines you launch yourself (not Prefect tasks) are not subject to Prefect’s concurrency limits.
- Your worker’s capacity/task runner still matters; the tag-based limit is an upper bound. The worker won’t exceed its own parallelism even if slots are available.
Example
1) Create the concurrency limit:
prefect concurrency-limit create limited 5
2) Tag your task and submit 10 of them:
from prefect import flow, task
import asyncio
@task(tags={"limited"})
async def do_work(i: int) -> int:
await asyncio.sleep(1)
return i
@flow
def my_flow():
futures = [do_work.submit(i) for i in range(10)]
return [f.result() for f in futures]
Only 5 do_work task runs will be Running at once; as one finishes, another queued task run will start.
Inspect active slots:
prefect concurrency-limit inspect limited
Docs: Tag-based concurrency limits