A distributed lock using Redis. Inspired by Sherlock.
$ pip install bullock
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
For more examples, see tests.