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.9.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.9-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

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

Hashes for dflockd_client-1.8.9.tar.gz
Algorithm Hash digest
SHA256 20a832cee4914b43333147b35df945390bb721de542cc66da61272e4f886758f
MD5 9ca4365c1136298bb0ad88f008130235
BLAKE2b-256 6b76e3265e82f680ea37fb332ec3ec10a47d43e3c6ca0ab480f97ddcd15c5bcf

See more details on using hashes here.

Provenance

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

Hashes for dflockd_client-1.8.9-py3-none-any.whl
Algorithm Hash digest
SHA256 59dd41e0f05247da81a5f4a87b978af9cf3f4c1aaf72b804b7ad5c50c470f336
MD5 5d3c3f3872acf9d27259991d696388fc
BLAKE2b-256 fee59855a5318af0df8ec6cd7c97877eced81dbb5f663e507768d98b6a094146

See more details on using hashes here.

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

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