File-based locks for Python for Linux and Windows
Project description
import locket
# Wait for lock
with locket.lock_file("path/to/lock/file"):
perform_action()
# Raise error if lock cannot be acquired immediately
with locket.lock_file("path/to/lock/file", timeout=0):
perform_action()
# Raise error if lock cannot be acquired after thirty seconds
with locket.lock_file("path/to/lock/file", timeout=30):
perform_action()
# Without context managers:
lock = locket.lock_file("path/to/lock/file")
try:
lock.acquire()
perform_action()
finally:
lock.release()
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
locket-0.1.1.tar.gz
(1.6 kB
view details)
File details
Details for the file locket-0.1.1.tar.gz.
File metadata
- Download URL: locket-0.1.1.tar.gz
- Upload date:
- Size: 1.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
503e4dab2235cebaa5104a055bd1653e912f333ed5c05772753784e03b2f4df6
|
|
| MD5 |
934bb2efb5d9885bc901473f02a0fe3d
|
|
| BLAKE2b-256 |
e0b34bbfe048511d708bfcf0a09bfb5d3f7f251090018aace86337509db16fea
|