Skip to main content

基于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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redis-fair-semaphore-0.1.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

redis_fair_semaphore-0.1.0-py3-none-any.whl (2.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page