Skip to main content

Distributed locking with DynamoDB

Project description

DynaLock
https://img.shields.io/pypi/v/dynalock.svg Documentation Status

Distributed locking implementation in python with DynamoDB

Getting Started

To install DynaLock, simply use pip:

$ pip install dynalock

DynaLock utilizes Python’s context manager making it easier and safer to manage locks. When used in a with statement, DynaLock automatically acquires the lock at the beginning of the block and releases it upon exiting, regardless of whether the block exits normally or with an exception. This eliminates the need for explicit release calls, reducing the boilerplate code and minimizing the risk of errors.

Example Usage:

from dynalock import DynaLock

# Initialize a distributed lock
distributed_lock = DynaLock(
    table_name='my_lock_table',
    region_name='us-west-2',
    lock_id='api_lock',
)

# Use the lock with a context manager
with distributed_lock.lock():
    # Protected code goes here
    # The lock is automatically managed
    print("This code is protected by the lock")
    print("Critical section executed")

# The lock is automatically released after exiting the block
print("This code is not protected by the lock")

History

0.1.0 (2024-03-30)

  • First release on PyPI.

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

dynalock-0.2.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

dynalock-0.2.0-py2.py3-none-any.whl (4.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dynalock-0.2.0.tar.gz.

File metadata

  • Download URL: dynalock-0.2.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.19

File hashes

Hashes for dynalock-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1224ac6a02f68440a827a763cdfdc2728d829af9c6813747d2ddebe9fa54833b
MD5 0ec00a936540426368e324dd7123b8e5
BLAKE2b-256 a3671658500574f0123904c080a8776429b052a7534be48771cb8f16375fb24c

See more details on using hashes here.

File details

Details for the file dynalock-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: dynalock-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.19

File hashes

Hashes for dynalock-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 117134e99a108c4b5f1f4be270f254b6d4bd898bed6e1a23a8863250dd557b1a
MD5 2e1a42ac8f966be34a793da899377b7f
BLAKE2b-256 fb240cc3650f07a3b9f395a2e5435d133720476775fd5afe892fb3d2fc1ff419

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