Skip to content

abeerupadhyay/py-redismutex

Repository files navigation

py-redismutex

Build Status Documentation Status PyPI version

Python implementation of mutex using redis

Installation

pip install redismutex

Usage

To apply mutex to a block of code, first create a redis connection object using redis.StrictRedis. This connection object is necessary as all the mutex keys are stored in redis. Now use the RedisMutex to create a mutex object.

import redis
from redismutex import RedisMutex

conn = redis.StrictRedis(host='localhost', port=6379, db=1)
mutex = RedisMutex(conn)
mutex_key = 'YOUR-MUTEX-KEY'

with mutex.acquire_lock(mutex_key):
    # your blocking code
    # goes here...
    print(mutex.key, mutex.value)

View detailed docs at py-redismutex.readthedocs.io

About

Python implementation of mutex using redis

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages