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
File details
Details for the file aioredis_semaphore-0.1.0.tar.gz
.
File metadata
- Download URL: aioredis_semaphore-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Linux/5.4.0-126-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdefd3540d5a59ae61ed93c5362bd1fe7c082ad466605150eed8123d0439c11a |
|
MD5 | 0c66d9a07eaf3d5e4bad38e328064b94 |
|
BLAKE2b-256 | 5644972779b4860c7c77e475940fb6a471fbe38805da13a6b2eda0a2cd5cb646 |
File details
Details for the file aioredis_semaphore-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: aioredis_semaphore-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Linux/5.4.0-126-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 578732f4f1cf32480aee580180dc5e64d7abc9b86c752622323fa2e02a4c1f4d |
|
MD5 | 906b7c8d18717a825569f34cb9101e06 |
|
BLAKE2b-256 | 322d9535df43323f1e2b34cf897515d26cb15d0beea7f7c3a98f9ff25ba2a8b0 |