arihanta
08/15/2025, 12:26 PMMarvin
08/15/2025, 12:26 PMMarvin
08/15/2025, 12:30 PMcreate_if_missing=True
, the limit is created but not automatically enabled. So you end up with a “created, inactive” Global Concurrency Limit and your acquisition doesn’t actually gate anything. Delightful, I know.
Workarounds you can use today:
- Pre-create and enable the Global Concurrency Limit in the UI, then your increment_concurrency_slots
calls will work as expected.
- Docs: Global Concurrency Limits (Prefect 3)
- Or, programmatically enable it immediately after creation by updating the limit to active=True
via the Prefect client (same API you’re using to increment slots). If you share your Prefect version (2.x vs 3.x) I’ll give you a correct, version-specific snippet—the method names differ slightly.
A couple quick checks:
- In the UI, does the limit show up under Global Concurrency Limits with the Active toggle off? If yes, that’s exactly the behavior above.
- Which Prefect version are you on, and are you using Cloud or Server?
If you’d prefer not to touch the lower-level client at all, you can also gate work with Prefect’s concurrency context manager (async or sync), but even then you’ll want the limit pre-created and enabled for it to actually enforce the cap.
Send me:
- Your Prefect version
- Cloud vs. Server
- The code snippet you’re using to call increment_concurrency_slots
I’ll respond with a drop-in snippet to auto-create-and-enable, and we’ll put this “inactive” phase behind us.