Lock class based on the creation of directories in a folder
Project description
This is a class that tries to limit the number of multiple simultaneous executions of a python script, on a local computer. It works by creating folders (using a pattern) under a folder. If the folder is successfully created, the execution gains the lock. Otherwise the script waits up to a configurable time to try to create the folder.
Example:
from lockdir import LockDir
lock = lockdir.LockDir(parallelruns=5, secondswait=300, lockdir="/tmp/lockdir.lock")
if not lock.acquire_lock():
print "Error acquiring lock"
sys.exit(1)
# do the job
lock.clean_lock()
Example:
from lockdir import LockDir
lock = lockdir.LockDir(parallelruns=5, secondswait=300, lockdir="/tmp/lockdir.lock")
if not lock.acquire_lock():
print "Error acquiring lock"
sys.exit(1)
# do the job
lock.clean_lock()
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
lockdir-0.1.tar.gz
(1.9 kB
view hashes)