skillfed

python-dynamodb-lock

Python library that emulates the java-based dynamo-db-client from awslabs

python-dynamodb-lock v0.9.1 519.5K downloads/30d#6,216 on PyPI54
Permissive license Apache Software License 2.0 DORMANT released

What it is and what it does

Python DynamoDB Lock is a distributed locking library built on DynamoDB that emulates the Java-based AmazonDynamoDBLockClient. It allows multiple processes or services to coordinate access to shared resources by acquiring named locks with configurable retry behavior, maintaining them through periodic heartbeats, and automatically releasing them after a configurable lease duration.

The library supports both coarse-grained and fine-grained locking, stores arbitrary application data alongside locks, and uses monotonically increasing clocks to handle clock skew. It notifies applications via callback if a lock is stolen or nearing expiry. However, the documentation explicitly notes that locks do not participate in distributed transactions—if a heartbeat is delayed beyond the lease duration, another client may acquire the lock while the original holder is still processing, leading to potential data inconsistency if not handled at the application level.

Use it for:

  • Coordinate database writes across multiple application instances to ensure only one process modifies a given resource at a time.
  • Implement leader election among distributed services using DynamoDB as the coordination backend.
  • Prevent concurrent execution of expensive batch jobs or scheduled tasks across a fleet of servers.
  • Serialize access to shared state stored in DynamoDB when multiple Lambda functions or microservices need to update it safely.
  • Build a distributed job queue where only one worker processes a given job at a time.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides distributed locking on top of DynamoDB with configurable retry semantics, heartbeat-based lease management, and lock-theft detection.

Yes, with conditions. The package solves a real problem—distributed locking on DynamoDB—and has no known vulnerabilities. However, dormant maintenance (no updates since 2018-10-28) and classifiers limited to Python 3.6 and 3.7 raise questions about compatibility with modern Python versions. Verify it works with your target Python and boto3 versions before relying on it in production. The documented limitations around distributed transactions require careful application-level handling.

Install

python-dynamodb-lock on PyPI

pip

pip install python-dynamodb-lock

uv

uv add python-dynamodb-lock

poetry

poetry add python-dynamodb-lock

Installing python-dynamodb-lock

Before you install

Low install friction with only boto3 and botocore as runtime dependencies. Maintenance is dormant—last release was 2018-10-28 with no updates since, though the repository remains active.

License in practice

Licensed under Apache Software License 2.0 (permissive), allowing use in most commercial and open-source projects with minimal restrictions.

Quickstart

pip install python-dynamodb-lock

from python_dynamodb_lock import DynamoDBLock
import boto3

dynamodb = boto3.resource('dynamodb')
lock = DynamoDBLock(dynamodb, 'lock-table-name')
lock.acquire('my-lock-name')

Requires an existing DynamoDB table and AWS credentials configured for boto3.

Verify before relying

  • Whether the package works reliably with Python versions beyond 3.7, given classifiers list only 3.6 and 3.7.
  • Current compatibility with recent boto3 and botocore versions and whether breaking changes have occurred since 2018.
  • Whether the lock-theft callback and heartbeat mechanism perform reliably under high-latency or GC-pause conditions.

Package facts

License Apache Software License 2.0 (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — boto3, botocore
Maintenance dormant — 2,847 days since the last release
Last repo commit
First released
Downloads 519,463/month — #6,216 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_dynamodb_lock-0.9.1-py2.py3-none-any.whl

Keywords: python_dynamodb_lock

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7

Tags

dynamodb distributed lockingaws dynamodb lock clientpython distributed locksdynamodb lease managementconcurrent access control dynamodblock heartbeat renewalmulti-process synchronization aws
dynamodbdistributed-lockingaws

More Distributed Computing packages