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
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 aioredis_semaphore-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 578732f4f1cf32480aee580180dc5e64d7abc9b86c752622323fa2e02a4c1f4d |
|
MD5 | 906b7c8d18717a825569f34cb9101e06 |
|
BLAKE2b-256 | 322d9535df43323f1e2b34cf897515d26cb15d0beea7f7c3a98f9ff25ba2a8b0 |