Simple PID based locking for cronjobs, UNIX scripts or python programs
Project description
[![PyPI version](https://img.shields.io/pypi/v/pidlock.svg)](https://pypi-hypernode.com/pypi/pidlock)
[![Build Status](https://travis-ci.org/sayanarijit/pidlock.svg?branch=master)](https://travis-ci.org/sayanarijit/pidlock)
# pidlock
Simple PID based locking for cronjobs, UNIX scripts or python programs
### Requirement:
* requires python (>2 or 3)
### Usage:
* Install with pip
```bash
sudo pip install -U pidlock
```
* Use it from inside python script
```python
import time
from pidlock import PIDLock
locker = PIDLock()
with locker.lock('sleepy_script'):
time.sleep(10)
```
* Use it as commandline/cron job
```bash
# 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
# Python Usage
locker = PIDLock(lockdir='~/.pidlock', verbose=True)
```
```bash
# Commandline usage
pidlock -n sleepy_script -c 'sleep 10' -l ~/.pidlock -v
# Same as
pidlock --name sleepy_script --command 'sleep 10' --lockdir ~/.pidlock --verbose
```
[![Build Status](https://travis-ci.org/sayanarijit/pidlock.svg?branch=master)](https://travis-ci.org/sayanarijit/pidlock)
# pidlock
Simple PID based locking for cronjobs, UNIX scripts or python programs
### Requirement:
* requires python (>2 or 3)
### Usage:
* Install with pip
```bash
sudo pip install -U pidlock
```
* Use it from inside python script
```python
import time
from pidlock import PIDLock
locker = PIDLock()
with locker.lock('sleepy_script'):
time.sleep(10)
```
* Use it as commandline/cron job
```bash
# 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
# Python Usage
locker = PIDLock(lockdir='~/.pidlock', verbose=True)
```
```bash
# 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
Release history Release notifications | RSS feed
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.1.tar.gz
(4.1 kB
view details)
File details
Details for the file pidlock-1.1.1.tar.gz
.
File metadata
- Download URL: pidlock-1.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1697b53a0b453c8b7db7568dcf7fb47f664064c8900b9f6ecab46aa77d7c614 |
|
MD5 | 24f9c4fc224c3be3bcb29961d6c1562d |
|
BLAKE2b-256 | 20d63e4f2b26dde94107cece6e7ce3de821d5599b4b7164d3ef2bdb58a097966 |