dflockd python client
Project description
dflockd-client
A Python client library for dflockd — a lightweight distributed lock server with FIFO ordering, automatic lease expiry, and background renewal.
Features
- Async and sync clients with automatic background lease renewal
- Distributed locks and counting semaphores with FIFO ordering
- Signals (pub/sub) with NATS-style wildcards and queue groups
- Two-phase acquisition (enqueue + wait)
- Multi-server sharding with consistent hashing
- TLS and token-based authentication
- Zero dependencies — pure Python 3.12+
Installation
pip install dflockd-client
# or: uv add dflockd-client
Quick start
Lock
from dflockd_client import SyncDistributedLock
with SyncDistributedLock("my-key") as lock:
print(f"acquired: {lock.token}")
# critical section — lease auto-renews in background
Async:
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
from dflockd_client import SyncDistributedSemaphore
with SyncDistributedSemaphore("pool", limit=3) as sem:
print(f"acquired: {sem.token}")
# up to 3 concurrent holders
Signals
from dflockd_client import SyncSignalConn
with SyncSignalConn(server=("127.0.0.1", 6388)) as sc:
sc.listen("events.>")
for sig in sc:
print(f"{sig.channel}: {sig.payload}")
break
Authentication and TLS
import ssl
ctx = ssl.create_default_context()
with SyncDistributedLock("my-key", auth_token="secret", ssl_context=ctx) as lock:
...
Multi-server sharding
servers = [("server1", 6388), ("server2", 6388), ("server3", 6388)]
with SyncDistributedLock("my-key", servers=servers) as lock:
... # key deterministically routes to the same server
For detailed guides, API reference, and more examples, see the documentation.
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-1.8.9.tar.gz.
File metadata
- Download URL: dflockd_client-1.8.9.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20a832cee4914b43333147b35df945390bb721de542cc66da61272e4f886758f
|
|
| MD5 |
9ca4365c1136298bb0ad88f008130235
|
|
| BLAKE2b-256 |
6b76e3265e82f680ea37fb332ec3ec10a47d43e3c6ca0ab480f97ddcd15c5bcf
|
Provenance
The following attestation bundles were made for dflockd_client-1.8.9.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-1.8.9.tar.gz -
Subject digest:
20a832cee4914b43333147b35df945390bb721de542cc66da61272e4f886758f - Sigstore transparency entry: 1059864633
- Sigstore integration time:
-
Permalink:
mtingers/dflockd-client-py@2e88c6c5a1a5f6edce3bcaefbf85335aac47a7e7 -
Branch / Tag:
refs/tags/v1.8.9 - Owner: https://github.com/mtingers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e88c6c5a1a5f6edce3bcaefbf85335aac47a7e7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dflockd_client-1.8.9-py3-none-any.whl.
File metadata
- Download URL: dflockd_client-1.8.9-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59dd41e0f05247da81a5f4a87b978af9cf3f4c1aaf72b804b7ad5c50c470f336
|
|
| MD5 |
5d3c3f3872acf9d27259991d696388fc
|
|
| BLAKE2b-256 |
fee59855a5318af0df8ec6cd7c97877eced81dbb5f663e507768d98b6a094146
|
Provenance
The following attestation bundles were made for dflockd_client-1.8.9-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-1.8.9-py3-none-any.whl -
Subject digest:
59dd41e0f05247da81a5f4a87b978af9cf3f4c1aaf72b804b7ad5c50c470f336 - Sigstore transparency entry: 1059864639
- Sigstore integration time:
-
Permalink:
mtingers/dflockd-client-py@2e88c6c5a1a5f6edce3bcaefbf85335aac47a7e7 -
Branch / Tag:
refs/tags/v1.8.9 - Owner: https://github.com/mtingers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e88c6c5a1a5f6edce3bcaefbf85335aac47a7e7 -
Trigger Event:
release
-
Statement type: