prefect.server.utilities.leasing

Classes

ResourceLease

LeaseStorage

Methods:

create_lease

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:
  • A ResourceLease object representing the lease.

read_lease

read_lease(self, lease_id: UUID) -> ResourceLease[T] | None
Read a resource lease. Args:
  • lease_id: The ID of the lease to read.
Returns:
  • A ResourceLease object representing the lease, or None if not found.

renew_lease

renew_lease(self, lease_id: UUID, ttl: timedelta) -> 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.

revoke_lease

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.

read_expired_lease_ids

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:
  • A list of UUIDs representing the expired leases.