Registry / database / aioredlock

aioredlock

JSON →
library0.7.3pypypiunverified

Asyncio implementation of Redis distributed locks, providing a reliable mutex mechanism for distributed systems. Current version 0.7.3, with low release cadence. Requires Python >=3.6.

pip install aioredlock
INSTALL
IMPORT
SIG · AIOREDLOCK
A
aioredlock
databasepythonv0.7.3
Install
2.0s avg
Import
1020ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.676s · 20.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.548s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Aioredlock
from aioredlock import Aioredlock
from aioredlock import Aioredlock

Basic usage: acquire and release a distributed lock using aioredlock.

import asyncio from aioredlock import Aioredlock async def main(): # Initialize lock manager with Redis connection lock_manager = Aioredlock([('localhost', 6379)]) # Acquire a lock lock = await lock_manager.lock("my_resource") if lock: print("Lock acquired") # Do critical work await asyncio.sleep(1) # Release the lock await lock_manager.unlock(lock) else: print("Failed to acquire lock") # Cleanly close connections await lock_manager.destroy() asyncio.run(main())
Debug
Known issues
gotchaThe unlock() method must be called with the lock object returned by lock(), not a string. Passing a string will raise an AttributeError.
fix
Always store the lock object from lock() and pass it to unlock().
affects: all
gotchaThe lock manager must be destroyed with await lock_manager.destroy() to close Redis connections. Forgetting to call destroy() will cause connection leaks.
fix
Use a try/finally block or context manager to ensure destroy() is called.
affects: all
deprecatedThe library relies on aioredis v1.x, which is deprecated. aioredis v2.x changed the API significantly, but aioredlock has not been updated.
fix
Pin aioredis<2 or consider migrating to a maintained alternative like redis-py (redis.asyncio).
affects: 0.7.3
Upgrade
Version history
0.7.3latest on PyPI · released Feb 8, 2022
Audit
Dependencies
redisrequiredRequired for Redis client.
aioredisrequiredRequired for async Redis client.
Agent activity
43 hits · last 30 days
node
36
OpenAI (training)
1
Resources
aioredlock — pip install aioredlock · libregistry