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.8.7.tar.gz (10.2 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.8.7-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dflockd_client-1.8.7.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

Hashes for dflockd_client-1.8.7.tar.gz
Algorithm Hash digest
SHA256 660c1ef3fe8763c3cc2d758b52441e655ca01b3d2823fa414a50d6b2a26b3c0e
MD5 729f9145012270b8c6367fcb1791e589
BLAKE2b-256 de9ee6310ad7ce54539c7028044a1d363ec3426a560abbcc19c8a08604d1bbc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for dflockd_client-1.8.7.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.8.7-py3-none-any.whl.

File metadata

  • Download URL: dflockd_client-1.8.7-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

Hashes for dflockd_client-1.8.7-py3-none-any.whl
Algorithm Hash digest
SHA256 21181708b7d43da9167ae3f71f642bec83375404bccbf8bc8c2ba53a4a025ce8
MD5 2326b576a67a02f7974adc240e5d693d
BLAKE2b-256 ee4566df4d43e7d713e91e293b89cb763619022b0da15342ea79f863dc01388f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dflockd_client-1.8.7-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