Skip to main content

Python DynamoDB Lock

https://img.shields.io/pypi/v/python_dynamodb_lock.svg https://img.shields.io/travis/whatnick/python_dynamodb_lock.svg Documentation Status

This is a fork of the currently unmaintained (2 years) of Python DynamoDB Lock project. In the spirit of open-source whatnick is maintaining this while there is some time. Any enhancements targeting this project can be sent here.

This is a general purpose distributed locking library built on top of DynamoDB. It is heavily “inspired” by the java-based AmazonDynamoDBLockClient library, and supports both coarse-grained and fine-grained locking.

Features

  • Acquire named locks - with configurable retry semantics

  • Periodic heartbeat/update for the locks to keep them alive

  • Auto-release the locks if there is no heartbeat for a configurable lease-duration

  • Notify an app-callback function if the lock is stolen, or gets too close to lease expiry

  • Store arbitrary application data along with the locks

  • Uses monotonically increasing clock to avoid issues due to clock skew and/or DST etc.

  • Auto-delete the database entries after a configurable expiry-period

Consistency Notes

Note that while the lock itself can offer fairly strong consistency guarantees, it does NOT participate in any kind of distributed transaction.

For example, you may wish to acquire a lock for some customer-id “xyz”, and then make some changes to the corresponding database entry for this customer-id, and then release the lock - thereby guaranteeing that only one process changes any given customer-id at a time.

While the happy path looks okay, consider a case where the application changes take a long time, and some errors/gc-pauses prevent the heartbeat from updating the lock. Then, some other client can assume the lock to be abandoned, and start processing the same customer in parallel. The original lock-client will recognize that its lock has been “stolen” and will let the app know through a callback event, but the app may have already committed its changes to the database. This can only be solved by having the application changes and the lock-release be part of a single distributed transaction - which, as indicated earlier, is NOT supported.

That said, in most cases, where the heartbeat is not expected to get delayed beyond the lock’s lease duration, the implementation should work just fine.

Refer to an excellent post by Martin Kleppmann on this subject: https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html

Credits

History

0.9.3 (2020-07-14)

  • Forked Release from whatnick via CI

0.9.2 (2020-07-13)

  • Forked Release from whatnick manual

0.9.1 (2019-10-29)

  • Main repository second release

0.9.0 (2018-10-28)

  • First release on PyPI.

Metadata

Release files for python-dynamodb-lock-whatnick 0.9.3

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

Source distribution (sdist)

Source distribution for python-dynamodb-lock-whatnick 0.9.3
File Size Uploaded Provenance Actions
python_dynamodb_lock_whatnick-0.9.3.tar.gz 27.0 kB Without provenance Details for python_dynamodb_lock_whatnick-0.9.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-dynamodb-lock-whatnick 0.9.3
File Interpreter ABI Platform Actions
python_dynamodb_lock_whatnick-0.9.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for python_dynamodb_lock_whatnick-0.9.3-py2.py3-none-any.whl

Total release size: 41.6 kB

Release files / python_dynamodb_lock_whatnick-0.9.3.tar.gz

Download URL python_dynamodb_lock_whatnick-0.9.3.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
45aab8aac3d2917780c98aa56adeab6daef6394df9720aeb17730d3ee6466602
BLAKE2b-256 checksum
How to use checksums
1c5ed04625f1351c954e9ff560e21072462bc4702a5a933a31dbe93da2cc9a67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

Release files / python_dynamodb_lock_whatnick-0.9.3-py2.py3-none-any.whl

Download URL python_dynamodb_lock_whatnick-0.9.3-py2.py3-none-any.whl
Size 14.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6bee6f7c6cd5200314b32e6b3b245584d57c2eb13c9b921ea0b33e593bbca4d2
BLAKE2b-256 checksum
How to use checksums
a0c735a1e78f452dcd0630d31cf119d9cc0702b7dfeb429599662f529f34f106
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

Security for python-dynamodb-lock-whatnick 0.9.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.3 This release

2 release files No provenance

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