def lockfile(lockfile_name, lock_wait_timeout=-1):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            lock = FileLock(lockfile_name)
            try:
                lock.acquire(lock_wait_timeout)
            except AlreadyLocked:
                return
            except LockTimeout:
                return
            try:
                result = func(*args, **kwargs)
            finally:
                lock.release()
            return result

        return wrapper
    return decorator
Only runs the method if the lockfile is not acquired.
dataset/ETHPy150Open bitmazk/django-libs/django_libs/decorators.py/lockfile