You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

redis-semaphore-async

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-semaphore-async

Redis Semaphore Async is a Python library that provides an asynchronous semaphore implementation using Redis as the backend.

0.0.4
pipPyPI
Maintainers
1

Redis-Semaphore-Async

Redis-Semaphore-Async is a Python library that provides an asynchronous semaphore implementation using Redis as the backend. It allows you to manage concurrent access to resources in a distributed environment.

Installation

To install Redis-Semaphore-Async, you can use pip:

pip install redis-semaphore-async

Usage

Here is an example of how to use Redis-Semaphore-Async:

import asyncio
from redis.asyncio import Redis
from redis_semaphore_async import Semaphore

async def main():
    redis = Redis(host='localhost', port=6379, decode_responses=True)
    async with Semaphore(redis=redis, task_name="test_semaphore", value=5):
        # Your code here
        pass
    # or 
    semaphore = Semaphore(redis=redis, task_name="test_semaphore", value=5)
    with semaphore:
        # Your code here
        pass
    # or
    semaphore = Semaphore(redis=redis, task_name="test_semaphore", value=5)
    await semaphore.acquire()
    # Your code here
    await semaphore.release()

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

Contributing

We welcome contributions! Please read our contributing guidelines for more information.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts