Redis Distributed Lock
Redis distributed lock for python3, using setnx and lua script, provide block and no-block function
Install
pip install redis-distributed-lock
Usage
from redis_distributed_lock import RDLock
import redis
redisconn = redis.Redis(host="127.0.0.1", port=6379, decode_responses=True)
lock = RDLock(redisconn)
# Prevent CPU consumption all the time,
# specify the sleeptime for block mode (default 100 millsec)
lock = RDLock(redisconn, sleeptime=1000)
# Specify lock prefix name (default: lock_)
lock = RDLock(redisconn, prefix="lock_")
# Using block method, default timeout is 0 (second)
# default key expire is 5000 millsec
key = "key"
try:
if lock.acquire(key, expire=3000, timeout=2):
# Do something
pass
finally:
lock.release(key)
# Using No-block method
lock.acquire_no_block(key)
Release files for redis-distributed-lock 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 | |
|---|---|---|---|
| redis_distributed_lock-1.3.tar.gz | 2.1 kB | Details |
Release files / redis_distributed_lock-1.3.tar.gz
| Download URL | redis_distributed_lock-1.3.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75ef6c500ec3a29c948979220ff5f062e43683a317afb8e0d09a57b66ee267fd
|
|
BLAKE2b-256 checksum How to use checksums |
6f9186669b22a5b162f880902ad45736a13bd73b5d85118410ae707e409e4de2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|