Skip to main content

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.

Documentation · Changelog

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dflockd_client-1.9.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dflockd_client-1.9.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file dflockd_client-1.9.0.tar.gz.

File metadata

  • Download URL: dflockd_client-1.9.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dflockd_client-1.9.0.tar.gz
Algorithm Hash digest
SHA256 36f4b085b60578b0e73095827ae7a873ab498de07525570221b9ec09474922f3
MD5 bf82b0a8fb57dfdfd23082b21557af72
BLAKE2b-256 4819fe41079dd65fc649f000e326911f8dd3e362ceb349bbbd626c46165a348c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dflockd_client-1.9.0.tar.gz:

Publisher: publish.yml on mtingers/dflockd-client-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dflockd_client-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: dflockd_client-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dflockd_client-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf2d7ea7f622e3c48a750edce2d9d917912aefd65b913011da468c9f6eb6c41a
MD5 574a264295446bd2b899a243d391f43f
BLAKE2b-256 4f5945a48bf636f835941edddc9d6b869ccd81780a53c1730f6aec10c266b0ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for dflockd_client-1.9.0-py3-none-any.whl:

Publisher: publish.yml on mtingers/dflockd-client-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page