A redis semaphore implementation using eval scripts
Project description
Redis Semaphore Eval
Usage
To acquire a lock:
from redis import Redis
from redis_semaphore_eval import semaphore
redis = Redis(host="localhost", port=6379, db=0)
key = "unique_lock_key"
with semaphore(redis, key=key, limit=2, expire_in=5, timeout=1) as lock_id:
...
To acquire a lock but continuously renew it in a background thread:
from redis import Redis
from redis_semaphore_eval import auto_renewing_semaphore
redis = Redis(host="localhost", port=6379, db=0)
key = "unique_lock_key"
with auto_renewing_semaphore(
redis,
key=key,
limit=2,
expire_in=5,
timeout=1,
auto_renewal_interval=4
) as lock_id:
...
Contributing
poetry run pre-commit install -t pre-commit -t commit-msg && poetry run pre-commit run --all
docker-compose up -d
poetry run python -m pytest
docker-compose down
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file redis-semaphore-eval-0.2.0.tar.gz
.
File metadata
- Download URL: redis-semaphore-eval-0.2.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.8 Linux/5.4.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c176bd17700de3d9fc62b5ee32648944f2133a42f6b8dc492cf5276cbd9a019 |
|
MD5 | cd93c9af86a77c84052685eb3f2d4d3f |
|
BLAKE2b-256 | 3f7dd0321262bb18cea536a0051db0e9d50dd803ba46869aa60af9e1d9af0b43 |
File details
Details for the file redis_semaphore_eval-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: redis_semaphore_eval-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.8 Linux/5.4.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7506019fd803adb2be66b95bdec37748736fdb28a8f45ae72d30b0357b06a9d2 |
|
MD5 | 3ca0950de15f936c4736f0a1f80fcb22 |
|
BLAKE2b-256 | e56ddd7289aba653b035a594f48f975b5ddf1f5b6f1c7eafd066308ff85ea8fa |