Skip to main content

No project description provided

Project description

=============== aioredis-semaphore

A distributed semaphore and mutex built on Redis.

Installation

To install aioredis-semaphore, simply::

pip install aioredis-semaphore

Examples

::

# -*- coding:utf-8 -*-
import anyio
from aioredis import Redis
from anyio import create_task_group, run

from aioredis_semaphore import Semaphore

semaphore = Semaphore(Redis(), count=2, namespace="example")


async def task(i: int) -> None:
    async with semaphore:
        print("id: {}".format(i))
        print("sleep...")
        await anyio.sleep(2)


async def main() -> None:
    async with create_task_group() as tg:
        for i in range(5):
            tg.start_soon(task, i)


if __name__ == "__main__":
    run(main)

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

aioredis_semaphore-0.1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

aioredis_semaphore-0.1.0-py3-none-any.whl (3.7 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