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.
from lockdir import LockDir
lock = lockdir.LockDir(parallelruns=5, secondswait=300, lockdir="/tmp/lockdir.lock")
if not lock.acquire_lock():
print "Error acquiring lock"
# do the job
TODO: Brief introduction on what you do with files - including link to relevant help section.