Redis based distributed lock
This is a simple distributed lock based on redis. It needs asyncio, otherwise it will not work!
You can install it simply with pip install rdlock_py
Usage
1, setup a redis client factory.
2, get a mutex and manage it with the context manager.
from rdlock import RDLockFactory, LockError, LockTimeout
factory = RDLockFactory("redis://:@localhost:30000/0")
try:
async with factory.get_mutex("test_mutex", "my_owner", 1.0):
# do your work here
pass
except LockTimeout:
print("failed to get lock in several seconds...")
except LockError:
print("Something wrong when communicating with redis")
Test
Use the uv run pytest will automatically test all cases.
Release files for rdlock_py 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rdlock_py-0.1.3.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rdlock_py-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / rdlock_py-0.1.3.tar.gz
| Download URL | rdlock_py-0.1.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86a5a2323b99004001bfc66997e8fd80577632e2cef53f977e1951ca2e10cec9
|
|
BLAKE2b-256 checksum How to use checksums |
7bba5515022d3edf39b1fa9f1a26bede9dd34c365c995bea69db43077803923a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / rdlock_py-0.1.3-py3-none-any.whl
| Download URL | rdlock_py-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a90c5f6b35f89cccc4f69ae7e96d8325506b5c9b894e9a39db84d98c21b7e9cf
|
|
BLAKE2b-256 checksum How to use checksums |
2d12be24b80209b6b86a0d528f8bdb487a059e5b1046b5ae8b99d4fcc07ce9ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|