Skip to main content

dimutex

Python library implementing asyncio-based distributed mutex on top of different providers.

Mutex is a synchronization primitive used to ensure that only one worker can do the given job. It can be used for safe access to a shared resource or for distributing tasks among multiple workers.

Currently, the only implemented provider is GCS (Google Cloud Storage). The implementation is based on the algorithm described in article A robust distributed locking algorithm based on Google Cloud Storage (see also Ruby implementation).

Features

  • Asynchronous.
  • Type-safe.
  • Atomic.
  • Expiration mechanism to ensure that a single worker won't hold the lock forever.
  • Supports emulators.

Installation

python3 -m pip install dimutex

Usage

import dimutex

async def do_something():
    lock = dimutex.GCS(bucket='bucket-name', name='lock-name')
    async with lock:
        try:
            await lock.acquire()
        except dimutex.AlreadyAcquiredError:
            return 'already acquired'
        try:
            ... # do something with the shared resuource
        finally:
            await lock.release()

Release files for dimutex 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dimutex 1.3.1
File Size Uploaded
dimutex-1.3.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dimutex 1.3.1
File Interpreter ABI Platform
dimutex-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / dimutex-1.3.1.tar.gz

Download URL dimutex-1.3.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4580bde97f08edad66b359787970c4a1f4c548458a7803f86a2de99e11db3ba6
BLAKE2b-256 checksum
How to use checksums
8573a71e2d08532a73d190ab3c3348f3f388a56725a0d1610b49f19329af156c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.25.1

Release files / dimutex-1.3.1-py3-none-any.whl

Download URL dimutex-1.3.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1f6beaf6eb274dc6685225f229861a5b1d9aac8ebfcc160066fe09e1260ce29
BLAKE2b-256 checksum
How to use checksums
d7e1c2c8f860e3ccdf9946e89fe09a6c0eeb1c637799767fce4c86a2a222b86c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.25.1

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page