Skip to main content

v1

lock_fences record, v1 — canonical aliases.

Consumers and the record registry import from here and never touch the inner module names, mirroring flow_specs/v1/__init__.py.

Module​

Submodules​

Classes​

ORM​

class ORM(**kwargs):

SQLAlchemy model for the lock_fences cache table.

One row per keyed lock: the fence that bars every holder but the latest from writing. A Prefect slot whose lease lapses while its holder still runs can be granted to a second holder, so the lock alone does not stop two writers. Each holder takes the fence's next token when it acquires the lock, and a write checks the token is still the latest before it lands, so the older of two holders is refused.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

Variables​

  • acquired_at : sqlalchemy.orm.base.Mapped[str | None]
  • fence_key : sqlalchemy.orm.base.Mapped[str]
  • holder_run_id : sqlalchemy.orm.base.Mapped[str | None]
  • tags : sqlalchemy.orm.base.Mapped[dict[str, typing.Any] | None]
  • token : sqlalchemy.orm.base.Mapped[int]

Record​

class Record(**data: Any):

The latest holder of one keyed lock, and the token it was given.

Attributes

  • fence_key: The lock fenced, e.g. a lineage limit name or metadata:<task_hash>.
  • token: The fence's token, one per acquisition; only the holder of the highest token may write.
  • holder_run_id: The run given token, when it named one.
  • acquired_at: When token was issued, ISO 8601.
  • tags: Arbitrary flat metadata.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static acquired_at : str | None
  • static fence_key : str
  • static holder_run_id : str | None
  • static model_config
  • static token : int