redlock
Distributed locks with Redis
What it is and what it does
RedLock is a Python implementation of the RedLock distributed locking algorithm, designed to coordinate access to shared resources across multiple independent Redis nodes. Unlike single-master Redis lock libraries, it addresses the race condition that occurs when a Redis master crashes before replicating a lock acquisition to its slave—by requiring a client to acquire the lock on a majority of independent Redis instances, it ensures safety even when individual nodes fail.
The package provides a threading.Lock-compatible API with both explicit acquire/release methods and context manager support, making it straightforward to protect critical sections in distributed systems. It also includes a RedLockFactory for efficiently reusing Redis client connections across multiple locks. However, the package has not been maintained since 2015 and targets Python 2 and early Python 3 versions, raising concerns about compatibility with current Python environments.
Use it for:
- Coordinate exclusive access to a shared resource across multiple application instances running on different machines.
- Prevent duplicate job execution in a distributed task queue or scheduler when multiple workers might pick up the same task.
- Protect critical sections in microservices that need to ensure only one service instance performs a time-sensitive operation at a time.
- Implement distributed mutual exclusion for database migrations or schema updates across a cluster without requiring a central lock server.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements the RedLock algorithm to provide distributed locks across multiple independent Redis nodes, preventing single-point-of-failure issues that arise with single-master Redis lock implementations.
No. While the package implements a sound algorithm and has no known vulnerabilities, it is abandoned (last release 2015-12-21) and targets Python 2 and Python 3.2–3.4. Compatibility with modern Python versions is unverified, and the lack of maintenance means bugs or security issues discovered in the future will not be addressed. For new projects, consider actively maintained alternatives or a more recent RedLock implementation.
Install
redlock on PyPI
pip
pip install redlockuv
uv add redlockpoetry
poetry add redlockInstalling redlock
Before you install
Low friction to install. However, the package is abandoned—last release was 2015-12-21 and last commit 2020-05-30. It targets Python 2 and early Python 3 versions (up to 3.4), so compatibility with modern Python environments is uncertain.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or redistribution in proprietary or open-source projects.
Quickstart
from redlock import RedLock
with RedLock("my_lock"):
# Critical section protected by distributed lock
pass
Requires one or more Redis servers to be running and accessible; by default connects to 127.0.0.1:6379. Multiple independent Redis masters (not replicated) are needed for the algorithm to provide safety guarantees.
Verify before relying
- Whether the package works reliably with modern Python versions (3.8+) despite targeting only up to 3.4
- Current state of the GitHub repository and whether it accepts pull requests or has been superseded
- Whether redis-py dependency is implicitly required and what version constraints apply
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,889 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 160,777/month — #10,651 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: redlock-1.2.0-py2-none-any.whl
Keywords: redis, lock, distributed
Tags
More Distributed Computing packages
gRPC Python is an HTTP/2-based RPC framework…
permissive · top 100 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
cloudpickleCloudpickle extends Python's standard pickle…
permissive · top 1,000 on PyPI
smart-openProvides a unified, open()-compatible Python…
permissive · top 1,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
rayRay is a distributed computing framework that…
permissive · top 1,000 on PyPI
aioredlockImplements the Redlock distributed lock…
permissive · top 15,000 on PyPI
python-redis-lockProvides a Redis-backed distributed lock with a…
permissive · top 5,000 on PyPI
redlock-pyImplements Redis-based distributed locks using…
permissive · top 15,000 on PyPI
python-dynamodb-lockProvides distributed locking on top of DynamoDB…
permissive · top 15,000 on PyPI
celery_oncePrevents duplicate execution and queuing of…
permissive · top 15,000 on PyPI
fastrlockA C-level re-entrant lock for CPython that…
permissive · top 5,000 on PyPI
celery-singletonPrevents duplicate Celery tasks from being…
permissive · top 15,000 on PyPI
PyMySQLLockProvides distributed locking primitives backed…
permissive · top 15,000 on PyPI
readerwriterlockProvides reader-writer lock implementations for…
permissive · top 5,000 on PyPI