skillfed

redlock

Distributed locks with Redis

redlock v1.2.0 160.8K downloads/30d#10,651 on PyPI215
Permissive license MIT Abandoned released

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 redlock

uv

uv add redlock

poetry

poetry add redlock

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4

Tags

distributed locks redisredlock algorithm pythonmulti-node redis lockingredis distributed synchronizationhigh-availability redis locksanti-race-condition redisredis master failover locks
distributed-lockingredisabandoned

More Distributed Computing packages