Skip to main content
=======
PyElock
=======

Pure Python wrapper for https://github.com/dustin/elock .

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
servers.

Note, if you are already using Twisted in your project, you should check out
dustin's wrapper at https://github.com/dustin/elock-twisted .

Usage
=====

Simple single lock:

try:
with pyelock.ELockSingle(('remote-server.domain.com', 11400), 'my_lock'):
# Do some stuff
time.sleep(10)
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(('remote-server.domain.com', 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
elock.unlock('my_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.

Release files for PyELock 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyELock 1.0.2
File Size Uploaded
PyELock-1.0.2.zip 4.4 kB Details

Release files / PyELock-1.0.2.zip

Download URL PyELock-1.0.2.zip
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0c44769ee4a1738cbd8cec734761ff0d538a958182177d182fb5b7e50d9b7596
BLAKE2b-256 checksum
How to use checksums
eaabde0678aeb76b2b9b89df19159ce3038a429e6d7cc9c5c9e4408abde3e3c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page