docs/v3/api-ref/python/prefect-concurrency-services.mdx
prefect.concurrency.servicesConcurrencySlotAcquisitionService <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/concurrency/services.py#L47" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
acquire <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/concurrency/services.py#L61" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>acquire(self, slots: int, mode: Literal['concurrency', 'rate_limit'], timeout_seconds: Optional[float] = None, max_retries: Optional[int] = None) -> httpx.Response
ConcurrencySlotAcquisitionWithLeaseService <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/concurrency/services.py#L91" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>A service that acquires concurrency slots with leases.
This service serializes acquisition attempts for a given set of limit names, preventing thundering herd issues when many tasks try to acquire slots simultaneously. Each unique set of limit names gets its own singleton service instance.
Args:
concurrency_limit_names: A frozenset of concurrency limit names to acquire slots from.Methods:
acquire <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/concurrency/services.py#L128" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>acquire(self, slots: int, mode: Literal['concurrency', 'rate_limit'], timeout_seconds: Optional[float] = None, max_retries: Optional[int] = None, lease_duration: float = 300, strict: bool = False, holder: Optional['ConcurrencyLeaseHolder'] = None) -> httpx.Response
Acquire concurrency slots with a lease, with retry logic for 423 responses.
Args:
slots: Number of slots to acquiremode: Either "concurrency" or "rate_limit"timeout_seconds: Optional timeout for the entire acquisition attemptmax_retries: Maximum number of retries on 423 LOCKED responseslease_duration: Duration of the lease in secondsstrict: Whether to raise errors for missing limitsholder: Optional holder information for the leaseReturns:
Raises:
httpx.HTTPStatusError: If the server returns an error other than 423 LOCKEDTimeoutError: If acquisition times outrelease_orphaned_lease <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/concurrency/services.py#L221" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>release_orphaned_lease(self, response: httpx.Response) -> 'concurrent.futures.Future[None]'
Release a lease that was delivered to a caller which is already gone.
The release is scheduled on the service's own loop so it reuses the client that acquired the slots, keeping acquisition and cleanup on the same API, and is tracked so that draining the service waits for it.