Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Pure Python wrapper for elock distributed locking server.

Project description


Pure Python wrapper for .

elock is "A simple, fault-tolerant distributed lock server in erlang." Using
it in Python allows you to do all sorts of cool stuff, like ensuring a Celery
task doesn't run more than once simultaneously, even across different Celery

Note, if you are already using Twisted in your project, you should check out
dustin's wrapper at .


Simple single lock:

with pyelock.ELockSingle(('', 11400), 'my_lock'):
# Do some stuff
except pyelock.LockInUse:
print "Can't do stuff, my_lock is in use"

If you want precise control over your locking behavior, or want to acquire
multiple locks, use the following code:

with pyelock.ELock(('', 11400)) as elock:
# Acquire a lock, waiting up to 30 seconds for it
if not elock.lock('my_lock', timeout=30.0):
print "Oh no, can't get my_lock"

# Acquire another lock, without waiting if it's locked
if not elock.lock('my_other_lock'):
print "Can't get my_other_lock"

# Do some stuff...

# Release first lock

# Do some other stuff...

# Note: you don't technically need to release locks right before the end
# of the 'with' block, since all locks held will be automatically released
# when the object is destroyed.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyELock, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size (4.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page