Skip to main content

Redis Semaphore Eval

codecov Actions Status Version PyPI - Wheel Pyversions

https://redislabs.com/ebook/part-2-core-concepts/chapter-6-application-components-in-redis/6-3-counting-semaphores/

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

Metadata

Release files for redis-semaphore-eval 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redis-semaphore-eval 0.3.0
File Size Uploaded
redis-semaphore-eval-0.3.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redis-semaphore-eval 0.3.0
File Interpreter ABI Platform
redis_semaphore_eval-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / redis-semaphore-eval-0.3.0.tar.gz

Download URL redis-semaphore-eval-0.3.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
480d2348e40580d5467cb45297ccc27719ec74a8a74c80d20be55f6bd4eefd5e
BLAKE2b-256 checksum
How to use checksums
a2d27eb2886a43f8b885fa09684160317a93f2cc58f77d792f8596671b331b45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-1047-azure

Release files / redis_semaphore_eval-0.3.0-py3-none-any.whl

Download URL redis_semaphore_eval-0.3.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6711d80d5a5d1f1484c7074d5259edd7dc4048701868c5eb064ec98bbda73c1
BLAKE2b-256 checksum
How to use checksums
1af386af47ba388c92ebd2c9cc3725b6820befdb8d0ff455b2227c132c9a287a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-1047-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page