基于Redis的信号量。
Project description
redis-fair-semaphore
基于Redis的信号量。
Install
pip install redis-fair-semaphore
使用方法
import redis
from redis_fair_semaphore import acquire_fair_semaphore
from redis_fair_semaphore import release_fair_semaphore
conn = redis.from_url("redis://redis/0")
def test():
sem_id = acquire_fair_semaphore(conn, "test_sem_name", 10)
try:
if sem_id:
print("Acquired...")
else:
print("NOT acquired...")
finally:
release_fair_semaphore(conn, "test_sem_name", sem_id)
if __name__ == "__main__":
test()
版本记录
v0.1.0
- 版本首发。
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for redis-fair-semaphore-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d83e371bf83e5f82a7953677b2826f0ce9c4a1a46add13cd42bf342e0d9e17 |
|
MD5 | 842ea726375add76b54ad73c3f61702d |
|
BLAKE2b-256 | 85f38cbf7f1f8fc8adf97c23562000711444415ae7b5b5f77affec193e13c7ad |
Close
Hashes for redis_fair_semaphore-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f50ce5091bc18fb3888638715fe639a926b2b3ce565aed3c125b28ffe770d50 |
|
MD5 | 16e0db422fde90af28d83a11600892ef |
|
BLAKE2b-256 | 5422f8a86c333956409574ac627ceb918547ef9e90867504b7ad679f58d452fb |