Wojciech Malinowski
10/19/2025, 6:46 PMMarvin
10/19/2025, 6:46 PMMarvin
10/19/2025, 6:50 PMprefect.concurrency context managers handle acquisition and renewal for you; you usually won’t need to manage renewals manually unless you’re calling the REST API yourself.
- The exact “why 24 hours (and not, say, 12 or 48)” is not explicitly documented in a public design note. It’s a pragmatic upper bound that covers long-running workloads while bounding risk from orphaned leases.
References
- Global concurrency limits guide: How to: Global concurrency limits
- API reference (Python server endpoints): Concurrency limits v2 API (Python)
- REST API: renew lease: Renew concurrency lease
- Leasing utilities overview: Leasing utilities
If your use case requires holding a slot longer than 24 hours without any renewals (e.g., an offline process you can’t heartbeat), let me know more about the scenario. We can suggest patterns to fit that workflow or log a feature request to make the max configurable.Wojciech Malinowski
10/19/2025, 6:52 PMMarvin
10/19/2025, 6:52 PMMarvin
10/19/2025, 6:55 PMprefect.concurrency.concurrency() or rate_limit() context managers—Prefect renews the lease for you while the context is active.
If you’re managing leases yourself (e.g., you called “increment with lease” directly), renew by calling the “Renew concurrency lease” endpoint with your lease_id and a new lease_duration (<= 86,400 seconds). Do this before the lease expires.
Example with curl:
curl -X POST "$PREFECT_API_URL/api/v2/concurrency_limits/renew-lease" \
-H "Authorization: Bearer $PREFECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lease_duration": 300
}'
When finished with the work, release the slots using the same `lease_id`:
curl -X POST "$PREFECT_API_URL/api/v2/concurrency_limits/decrement-with-lease" \
-H "Authorization: Bearer $PREFECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "lease_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }'
Docs for the endpoints and payloads:
- Bulk increment with lease: bulk-increment-active-slots-with-lease
- Renew lease: renew-concurrency-lease
- Decrement with lease: bulk-decrement-active-slots-with-lease
If you want, I can share a small heartbeat loop snippet that periodically renews the lease in a background task.Wojciech Malinowski
10/19/2025, 6:57 PMMarvin
10/19/2025, 6:57 PMMarvin
10/19/2025, 7:00 PM