Distributed lock for Python using Redis
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bullock
tests
.gitignore
.travis.yml
Dockerfile-2.7
Dockerfile-3.3
Dockerfile-3.4
Dockerfile-3.5
Dockerfile-3.6
Dockerfile-3.7
MANIFEST.in
README.rst
docker-compose.yml
requirements-dev.txt
requirements.txt
setup.py
wait-for-redis.sh

README.rst

Bullock

A distributed lock using Redis. Inspired by Sherlock.

https://travis-ci.org/jbochi/bullock.svg?branch=master

Installation

$ pip install bullock

Usage

from bullock import Bullock
lock = Bullock(host="redis-hostname", key="my-first-lock", ttl=3600)
lock.acquire(blocking=True)
# do critical work here
lock.release()

You can also use the with statement:

from bullock import Bullock
with Bullock(host="redis-hostname", key="my-first-lock", ttl=3600):
    # do critical work here

Also supports using redis cluster:

from bullock import Bullock
lock = Bullock(host="redis-hostname", key="my-first-lock", ttl=3600, redis_cluster=True)
lock.acquire(blocking=True)
# do critical work here
lock.release()

For more examples, see tests.