Quick Start¶
You need a running dflockd server. By
default, the client connects to 127.0.0.1:6388.
Acquire a lock¶
If the lock cannot be acquired within acquire_timeout_s, the context manager
raises TimeoutError.
Manual acquire and release¶
For cases where a context manager doesn't fit:
acquire() returns False on a server-side timeout (no slot opened in
time). Network-level timeouts surface as TimeoutError.
Acquire a semaphore¶
A semaphore allows up to limit concurrent holders on the same key. The
API is identical to DistributedLock aside from the required limit.
A Semaphore with limit=1 is exactly equivalent to a Lock. Mixing the
two on the same key surfaces LimitMismatchError.
See Examples for FIFO ordering, two-phase acquisition, authentication, TLS, and sharding. See Architecture for how the client works inside.