Skip to main content

dflockd python client

Project description

dflockd-client

A Python client for dflockd — a distributed FIFO lock and counting-semaphore server.

Documentation · Changelog

Features

  • Sync and async clients — pick the one that matches your runtime
  • Distributed locks and counting semaphores with FIFO ordering
  • Single-phase acquire and two-phase enqueue + wait
  • Background lease renewal — call acquire, hold for as long as you need
  • Multi-server sharding (deterministic CRC-32; matches the Go and TypeScript clients)
  • TLS and shared-secret authentication
  • Zero runtime dependencies; Python 3.12+

Install

pip install dflockd-client
# or
uv add dflockd-client

Quick start

A running dflockd server on 127.0.0.1:6388 is the only prerequisite.

Lock

from dflockd_client import SyncDistributedLock

with SyncDistributedLock("my-key") as lock:
    # critical section — lease auto-renews in a daemon thread
    print(f"acquired: {lock.token}")
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

Up to limit concurrent holders on the same key:

from dflockd_client import SyncDistributedSemaphore

with SyncDistributedSemaphore("pool", limit=3) as sem:
    print(f"slot: {sem.token}")

Authentication and TLS

import ssl
from dflockd_client import SyncDistributedLock

with SyncDistributedLock(
    "my-key",
    auth_token="shared-secret",
    ssl_context=ssl.create_default_context(),
) as lock:
    ...

Multi-server sharding

from dflockd_client import SyncDistributedLock

with SyncDistributedLock(
    "my-key",
    servers=[("a", 6388), ("b", 6388), ("c", 6388)],
) as lock:
    # the same key always routes to the same server
    ...

See the docs for two-phase acquisition, exception handling, low-level transport, and more.

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-2.0.0.tar.gz (15.7 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-2.0.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dflockd_client-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ce17e1a14f7b53cea175ea86b842a7ca08656e40fe322edc70b0969982fd6dc8
MD5 e485eb19126ab7e6dc48ed28625d6aba
BLAKE2b-256 bb3a0713ad4698cbe4c59e1e1debb5fb13cdefaff564f91b545092a5f1a00f2b

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for dflockd_client-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df9202329779975916a4298ff4d280167f28fe59993f51104d65f678353f6c97
MD5 82f74d5dc92ff55d058398bacaab874a
BLAKE2b-256 3e22e934b60cb2057ff75f4f86684731781ba6b0f4aeeef9f95599f8c8ce80da

See more details on using hashes here.

Provenance

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