Skip to main content

DynamoDB Persistent Lock

Project description

Getting Started

  1. Install the library

% python3 -m pip install dynamodb-persistent-lock
  1. Usage

Non-async DynamoDB local download:

from dynamodb_persistent_lock import (
    DynamoDBPersistentLockFactory,
    DynamoDBPersistentLockClient,
)
from datetime import timedelta
...
# Create a lock factory
lock_factory = DynamoDBPersistentLockFactory(
    table_name="locks",
    region_name="eu-central-1",
    partition_key_name="lock_key",
    sort_key_name="sort_key",
    record_version_number_name="rvn",
    heartbeat_period=timedelta(seconds=10),
    ttl_attribute_name="expire_at",
    ttl_heartbeat_multiplier=3,
)
lock_factory.ensure_table()
...
# Open a lock client
lock_client = lock_factory.open_lock_client()
try:
    lock_token = lock_client.try_acquire_lock("my_lock_key")
    ...
    while lock_client.lock_acquired(lock_token):
        # Lock-guarded code here.
finally:
    lock_client.close()

Features

  • Creates a new lock, if there is none, in DynamoDB table.

  • Reacquires stale existing lock based on the ttl column value.

  • Keeps extending the ttl of an acquired lock with a given heartbeat rate.

Credits

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

dynamodb_persistent_lock-0.0.5.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamodb_persistent_lock-0.0.5-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file dynamodb_persistent_lock-0.0.5.tar.gz.

File metadata

  • Download URL: dynamodb_persistent_lock-0.0.5.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dynamodb_persistent_lock-0.0.5.tar.gz
Algorithm Hash digest
SHA256 52660786dc6ca22a81d914cc5646f71411855aa654020ee01b829a2f6824e86c
MD5 000b03dfea7494466b4d88486775e61b
BLAKE2b-256 28f1fd27411c40ed1d2118e7267207f46294015504085a307fbe0c0669697d5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynamodb_persistent_lock-0.0.5.tar.gz:

Publisher: publish_pypi.yaml on timheiko/dynamodb-persistent-lock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynamodb_persistent_lock-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamodb_persistent_lock-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4c4c17533c560eb603a7f3e3fcd068fd0c11ab2bb7ac1a4c7476fb00ee542983
MD5 e5c6333b44732f63c07ba8ad58e7cb90
BLAKE2b-256 5efe8b850be89ede775a06ed8d53aced8c5b008cbb3e6288a3e2723e6aedd2a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynamodb_persistent_lock-0.0.5-py3-none-any.whl:

Publisher: publish_pypi.yaml on timheiko/dynamodb-persistent-lock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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