Super simple file based locking
Project description
ezlock
Super simple file-based locking:
# first.py
from ezlock import Lock
import time
with Lock():
print("I got the lock and I'm keeping it for 20s")
time.sleep(20)
and
# second.py
...
with Lock():
print("Trying to get a lock too")
running
>>> python3 first.py &
I got the lock and I'm keeping it for 20s
>>> echo "before 20s"
before 20s
>>> python3 second.py
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.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ezlock-0.1.3.tar.gz.
File metadata
- Download URL: ezlock-0.1.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.7.3 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5cc004a47ce580f3b931a803dce5278dbb025f3f9fe5f816d65e29e32b6edbc
|
|
| MD5 |
4ffd7789bd20e192d8cf282a95d7e62c
|
|
| BLAKE2b-256 |
c0fc64634815fce2f6d7342f02565cf31cbb6494a3d5c7fa600c547b9cc9c99b
|
File details
Details for the file ezlock-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ezlock-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.7.3 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6692ed22c0d086b2b248102a76345dc16e2873299cb103b1980e550ab5fca15
|
|
| MD5 |
b3eec77f5b31f249ec19db8d086cc5a4
|
|
| BLAKE2b-256 |
a61c73bca07af468e6c00790e6de831988a6099c99410cc51d26353289de3f27
|