pidlock
Simple PID based locking for cronjobs, UNIX scripts or python programs. Copes with locking between hosts.
Requirement
- requires python3
Usage
- Install with pip
sudo pip install -U pidlock
- Use it from inside python script
import time
from pidlock import PIDLock
locker = PIDLock()
with locker.lock('sleepy_script'):
time.sleep(10)
- Use it as commandline/cron job
# To display help menu
pidlock -h # Or pidlock --help
# Example usage
pidlock -n sleepy_script -c 'sleep 10'
# Same as
pidlock --name sleepy_script --command 'sleep 10'
Customization:
- You can pass PID file location, verbosity, time limit and minimum interval as arguments
# Python Usage
locker = PIDLock(lockdir='~/.pidlock', verbose=True)
with locker.lock('sleepy_script', wait=10, mininterval=1):
time.sleep(10)
# Commandline usage
pidlock -n sleepy_script -c 'sleep 10' -l ~/.pidlock -v -w 10 -m 1
# Same as
pidlock --name sleepy_script --command 'sleep 10' --lockdir ~/.pidlock --verbose --wait 10 --mininterval 1
Contributions
Originally written and published by Arijit Basu. Adaptation to cope with race conditions by Keiran Raine (ongoing owner/support).
Metadata
Release files for pidlock 3.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pidlock-3.0.2.linux-x86_64.tar.gz | 7.2 kB | Without provenance | Details for pidlock-3.0.2.linux-x86_64.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pidlock-3.0.2-py3-none-any.whl | Python 3 | none | any | Details for pidlock-3.0.2-py3-none-any.whl |
Total release size: 12.7 kB
Release files / pidlock-3.0.2.linux-x86_64.tar.gz
| Download URL | pidlock-3.0.2.linux-x86_64.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5748623848d4f4356b1813fde75d64b9e014905f2a0ca6ed3ed15675969c16a3
|
|
BLAKE2b-256 checksum How to use checksums |
a80876f1259d62e624efff55ad3f6ce09080fc0a5f3bea4af3ed2c6059b97e2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / pidlock-3.0.2-py3-none-any.whl
| Download URL | pidlock-3.0.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33cb0706ebb32c7acc68695f57265f25e40d13f14509295b0726f5a12f9c9d76
|
|
BLAKE2b-256 checksum How to use checksums |
cf48ee95c33609b9de8233f9364545ab0e45b4f5f3564a3faa6efe147066aaf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for pidlock 3.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.