dflockd python client
Project description
dflockd-client
A Python client for dflockd — a distributed FIFO lock and counting-semaphore server.
Features
- Sync and async clients — pick the one that matches your runtime
- Distributed locks and counting semaphores with FIFO ordering
- Single-phase
acquireand two-phaseenqueue+wait - Background lease renewal — call
acquire, hold for as long as you need - Multi-server sharding (deterministic CRC-32; matches the Go and TypeScript clients)
- TLS and shared-secret authentication
- Zero runtime dependencies; Python 3.12+
Install
pip install dflockd-client
# or
uv add dflockd-client
Quick start
A running dflockd server on
127.0.0.1:6388 is the only prerequisite.
Lock
from dflockd_client import SyncDistributedLock
with SyncDistributedLock("my-key") as lock:
# critical section — lease auto-renews in a daemon thread
print(f"acquired: {lock.token}")
import asyncio
from dflockd_client import AsyncDistributedLock
async def main():
async with AsyncDistributedLock("my-key") as lock:
print(f"acquired: {lock.token}")
asyncio.run(main())
Semaphore
Up to limit concurrent holders on the same key:
from dflockd_client import SyncDistributedSemaphore
with SyncDistributedSemaphore("pool", limit=3) as sem:
print(f"slot: {sem.token}")
Authentication and TLS
import ssl
from dflockd_client import SyncDistributedLock
with SyncDistributedLock(
"my-key",
auth_token="shared-secret",
ssl_context=ssl.create_default_context(),
) as lock:
...
Multi-server sharding
from dflockd_client import SyncDistributedLock
with SyncDistributedLock(
"my-key",
servers=[("a", 6388), ("b", 6388), ("c", 6388)],
) as lock:
# the same key always routes to the same server
...
See the docs for two-phase acquisition, exception handling, low-level transport, and more.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dflockd_client-2.0.1.tar.gz.
File metadata
- Download URL: dflockd_client-2.0.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11016e338b3d09001878668ff7bfe0d056273809c60d290d5e17a5636c9ca8e2
|
|
| MD5 |
a0bb5508075b451d0bb8627e8772df29
|
|
| BLAKE2b-256 |
9b57397be5bc273013d72b3ed16fa6de9d457e5b02c915bc0a8e2815a2683c56
|
Provenance
The following attestation bundles were made for dflockd_client-2.0.1.tar.gz:
Publisher:
publish.yml on mtingers/dflockd-client-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dflockd_client-2.0.1.tar.gz -
Subject digest:
11016e338b3d09001878668ff7bfe0d056273809c60d290d5e17a5636c9ca8e2 - Sigstore transparency entry: 1449439721
- Sigstore integration time:
-
Permalink:
mtingers/dflockd-client-py@b0cd0a65b31ad968b59006c43b27eff2615b3f94 -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/mtingers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0cd0a65b31ad968b59006c43b27eff2615b3f94 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dflockd_client-2.0.1-py3-none-any.whl.
File metadata
- Download URL: dflockd_client-2.0.1-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17f15360902dfcd8176491fb4455c110d3b49224bfa633afd678d3a3a080a953
|
|
| MD5 |
f77641bce17c81b41460309efa0f59b8
|
|
| BLAKE2b-256 |
cf1d778357448dc37fbb52ebf0e5f718e1c97e91a62ef3b1c7bad171369f4209
|
Provenance
The following attestation bundles were made for dflockd_client-2.0.1-py3-none-any.whl:
Publisher:
publish.yml on mtingers/dflockd-client-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dflockd_client-2.0.1-py3-none-any.whl -
Subject digest:
17f15360902dfcd8176491fb4455c110d3b49224bfa633afd678d3a3a080a953 - Sigstore transparency entry: 1449439726
- Sigstore integration time:
-
Permalink:
mtingers/dflockd-client-py@b0cd0a65b31ad968b59006c43b27eff2615b3f94 -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/mtingers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0cd0a65b31ad968b59006c43b27eff2615b3f94 -
Trigger Event:
release
-
Statement type: