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

Uploaded Python 3

File details

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

File metadata

  • Download URL: dflockd_client-1.8.8.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.8.tar.gz
Algorithm Hash digest
SHA256 a6fdd22899a51d4c4674593bc86292508b55a55819b60c3a8aebc744dea186e9
MD5 8120e879861e63d35abd44712c9af6ef
BLAKE2b-256 601869fae71b7a6e153c4d7054335a8b45de5a1b2f0b17c3a9241f3cbcf2b834

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dflockd_client-1.8.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a972ad42f82df924c1bc79a17a0182ffcaef3b894071e3ca771050083cdf7b
MD5 3fcbee1946fb56ced1aec705f73c32a0
BLAKE2b-256 fdd5aa054ef17e1c53e2170bc97c7d28c732fefb5450d42d4027f59b90836e99

See more details on using hashes here.

Provenance

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