docs/v3/api-ref/python/prefect-server-utilities-leasing.mdx
prefect.server.utilities.leasingResourceLease <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L13" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>LeaseStorage <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L21" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
create_lease <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L22" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_lease(self, resource_ids: list[UUID], ttl: timedelta, metadata: T | None = None) -> ResourceLease[T]
Create a new resource lease.
Args:
resource_ids: The IDs of the resources that the lease is associated with.ttl: How long the lease should initially be held for.metadata: Additional metadata associated with the lease.Returns:
read_expired_lease_ids <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L74" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_expired_lease_ids(self, limit: int = 100) -> list[UUID]
Read the IDs of expired leases.
Args:
limit: The maximum number of expired leases to read.Returns:
read_lease <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L38" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_lease(self, lease_id: UUID) -> ResourceLease[T] | None
Read a resource lease.
Args:
lease_id: The ID of the lease to read.Returns:
renew_lease <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L50" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>renew_lease(self, lease_id: UUID, ttl: timedelta) -> bool | None
Renew a resource lease.
Args:
lease_id: The ID of the lease to renew.ttl: The new amount of time the lease should be held for.Returns:
revoke_lease <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/utilities/leasing.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>revoke_lease(self, lease_id: UUID) -> None
Release a resource lease by removing it from list of active leases.
Args:
lease_id: The ID of the lease to release.