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

Super simple file based locking

Project description


Super simple file-based locking:

from ezlock import Lock
import time

with Lock():
    print("I got the lock and I'm keeping it for 20s")


with Lock():
    print("Trying to get a lock too")


>>> python3 &
I got the lock and I'm keeping it for 20s
>>> echo "before 20s"
before 20s
>>> python3
locking.LockError: Attempted to acquire on already locked lock!

Lock files have an owner. A lock can check if it owns a file with lock.mine. Locks will only release a lock that's not theirs if it's forced i.e. lock.release(force=True).

You can wait for a lock to be released with Lock.wait()

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 ezlock, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size ezlock-0.1.3-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ezlock-0.1.3.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page