Skip to main content

Mutex implementation for distributed systems.

Project description

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()

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

dimutex-1.3.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

dimutex-1.3.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file dimutex-1.3.1.tar.gz.

File metadata

  • Download URL: dimutex-1.3.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for dimutex-1.3.1.tar.gz
Algorithm Hash digest
SHA256 4580bde97f08edad66b359787970c4a1f4c548458a7803f86a2de99e11db3ba6
MD5 e233c8f3ab8b2a30d1fba037a1bfe824
BLAKE2b-256 8573a71e2d08532a73d190ab3c3348f3f388a56725a0d1610b49f19329af156c

See more details on using hashes here.

File details

Details for the file dimutex-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: dimutex-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for dimutex-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1f6beaf6eb274dc6685225f229861a5b1d9aac8ebfcc160066fe09e1260ce29
MD5 cdf47a152c3caad807d81cdd381aa161
BLAKE2b-256 d7e1c2c8f860e3ccdf9946e89fe09a6c0eeb1c637799767fce4c86a2a222b86c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page