entorin

Lease

Named coordination across runs and processes. Two parallel runs serialize on a shared resource without reinventing a lock service.

Named coordination so two parallel runs serialize on a shared resource. FsLease is flock-based per-machine; the protocol is Redis-shaped so a future RedisLease is a drop-in.

from entorin.lease import FsLease, LeaseClient

lease  = LeaseClient(backend=FsLease(Path("lease_root")), bus=bus)
handle = await lease.acquire(ctx, "user:42:prefs", ttl_seconds=30, wait_timeout=5)
try:
    ...
finally:
    await lease.release(ctx, handle)

Behaviour

  • Capability: lease
  • kill -9 on the holder releases the flock automatically — no zombie deadlocks
  • TTL is informational with FsLease, not enforced. For “force-eject after TTL even if alive”, swap in a Redis-backed adapter

Reference adapter

  • FsLeaseflock over a directory; works across processes on one machine

For cross-host coordination, implement the Lease protocol against Redis / etcd / Zookeeper. The protocol is intentionally Redis-shaped to keep the swap mechanical.