Skip to main content

Simple PID based locking for cronjobs, UNIX scripts or python programs

Project description

PyPI version Build Status

pidlock

Simple PID based locking for cronjobs, UNIX scripts or python programs

Requirement:

  • requires python (>2 or 3)

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 and verbosity as arguments
# Python Usage
locker = PIDLock(lockdir='~/.pidlock', verbose=True)
# Commandline usage
pidlock -n sleepy_script -c 'sleep 10' -l ~/.pidlock -v

# Same as
pidlock --name sleepy_script --command 'sleep 10' --lockdir ~/.pidlock --verbose

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

pidlock-1.1.5.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file pidlock-1.1.5.tar.gz.

File metadata

  • Download URL: pidlock-1.1.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pidlock-1.1.5.tar.gz
Algorithm Hash digest
SHA256 d7a5b53dd23f5f83ddb7b324753aea40a89dab24dab3d1977c9432179ec852ee
MD5 15a2e8e8f4fc3b49be31abf79c2e8814
BLAKE2b-256 f42681837a5c22bdb039313981aedb8e52e50366e142bd5ce9364399ebd50aed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page