All Projects → jbochi → bullock

jbochi / bullock

Licence: other
Distributed lock for Python using Redis

Programming Languages

python
139335 projects - #7 most used programming language
Roff
2310 projects
shell
77523 projects

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].