Skip to main content

prefect.server.api.concurrency_limits

Routes for interacting with concurrency limit objects. This module provides a V1 API adapter that routes requests to the V2 concurrency system. After the migration, V1 limits are converted to V2, but the V1 API continues to work for backward compatibility.

Functions

create_concurrency_limit

create_concurrency_limit(concurrency_limit: schemas.actions.ConcurrencyLimitCreate, response: Response, db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.ConcurrencyLimit
Create a task run concurrency limit. For more information, see https://docs.prefect.io/v3/concepts/tag-based-concurrency-limits.

read_concurrency_limit

read_concurrency_limit(concurrency_limit_id: UUID = Path(..., description='The concurrency limit id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.ConcurrencyLimit
Get a concurrency limit by id. The active slots field contains a list of TaskRun IDs currently using a concurrency slot for the specified tag.

read_concurrency_limit_by_tag

read_concurrency_limit_by_tag(tag: str = Path(..., description='The tag name', alias='tag'), db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.ConcurrencyLimit
Get a concurrency limit by tag. The active slots field contains a list of TaskRun IDs currently using a concurrency slot for the specified tag.

read_concurrency_limits

read_concurrency_limits(limit: int = dependencies.LimitBody(), offset: int = Body(0, ge=0), db: PrefectDBInterface = Depends(provide_database_interface)) -> Sequence[schemas.core.ConcurrencyLimit]
Query for concurrency limits. For each concurrency limit the active slots field contains a list of TaskRun IDs currently using a concurrency slot for the specified tag.

reset_concurrency_limit_by_tag

reset_concurrency_limit_by_tag(tag: str = Path(..., description='The tag name'), slot_override: Optional[List[UUID]] = Body(None, embed=True, description='Manual override for active concurrency limit slots.'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None

delete_concurrency_limit

delete_concurrency_limit(concurrency_limit_id: UUID = Path(..., description='The concurrency limit id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None

delete_concurrency_limit_by_tag

delete_concurrency_limit_by_tag(tag: str = Path(..., description='The tag name'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None

increment_concurrency_limits_v1

increment_concurrency_limits_v1(names: List[str] = Body(..., description='The tags to acquire a slot for'), task_run_id: UUID = Body(..., description='The ID of the task run acquiring the slot'), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[MinimalConcurrencyLimitResponse]
Increment concurrency limits for the given tags. During migration, this handles both V1 and V2 limits to support mixed states. Post-migration, it only uses V2 with lease-based concurrency.

decrement_concurrency_limits_v1

decrement_concurrency_limits_v1(names: List[str] = Body(..., description='The tags to release a slot for'), task_run_id: UUID = Body(..., description='The ID of the task run releasing the slot'), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[MinimalConcurrencyLimitResponse]
Decrement concurrency limits for the given tags. Finds and revokes the lease for V2 limits or decrements V1 active slots. Returns the list of limits that were decremented.

Classes

Abort

Delay

I