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.3.0.tar.gz (29.2 kB view hashes)

Uploaded Source

Built Distribution

dynalock-0.3.0-py2.py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 2 Python 3

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