Skip to content

locks

etl_craft.engine.locks

The named cross-process locks held in the Engine DB.

MIGRATE module-attribute

MIGRATE = EngineLock('migrate', 8241007)

Serializes init-db and migrate, so two runs never apply the same file twice.

CLONE module-attribute

CLONE = EngineLock('clone', 8241008)

Serializes cloning, so two runs finishing together never write the same mirror at once.

EngineLock dataclass

A lock every process reaching the same Engine DB contends for.

hold

hold(engine: Engine, wait_seconds: float = 0) -> AbstractContextManager[None]

Hold the lock for the with body; 0 waits indefinitely.

target

target(name: str) -> EngineLock

Serialize target mutations and hash-contract publication across processes.

advisory_key

advisory_key(name: str) -> int

Hash an exact lock namespace to PostgreSQL's signed 64-bit advisory key.