Skip to main content

pyredlock - A Redis distributed lock implementation in Python

This python lib implements the Redis-based distributed lock manager algorithm described in this blog post.

How to use it?

To create a lock manager:

from pyredlock import RedisClient
from pyredlock import Redlock, Lock

...
client = RedisClient(client_conf={
    "endpoint": "localhost:6379",
    "password": "your_redis_password",
    "db": 0,
    "socket_timeout": 0.5,
    "socket_connect_timeout": 0.25
})
lock_mgr = Redlock(connections=[client.get_connection()], async_mode=False)
...

To acquire a lock:

...
success, my_lock = lock_mgr.lock("my_resource_name", 1000)
...

To release a lock:

...
lock_mgr.unlock(my_lock)
...

To extend your ownership of a lock that you already own:

...
lock_mgr.extend(my_lock, 1000)
...

Disclaimer: This implementation is currently a proposal, it was not formally analyzed. Make sure to understand how it works before using it in your production environments.

Metadata

Release files for pyredlock 1.0.0

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

Source distribution (sdist)

Source distribution for pyredlock 1.0.0
File Size Uploaded
pyredlock-1.0.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyredlock 1.0.0
File Interpreter ABI Platform
pyredlock-1.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.4 kB

Release files / pyredlock-1.0.0.tar.gz

Download URL pyredlock-1.0.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
89e6255f4cadd4f2288e177415adbb07147aec971a36d5ef3c516c3923c047b3
BLAKE2b-256 checksum
How to use checksums
31679a227e4ade8acf07c87c5ef028acfd75e7fa20bc9d87fa1a6638f4356cba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Release files / pyredlock-1.0.0-py2.py3-none-any.whl

Download URL pyredlock-1.0.0-py2.py3-none-any.whl
Size 10.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5642227d97d9d8a8c0adb598662ea867e9dd64f49ac5c7aef709d554e436363d
BLAKE2b-256 checksum
How to use checksums
6c23826dac893e6942456ff1480ed4d5da6b1da4a6d119116ea562b3ef6ce969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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