def lock_file(path):
    """File based lock on ``path``.

    Creates a file based lock. When acquired, other processes or threads are
    prevented from acquiring the same lock until it is released.
    """
    with _paths_lock:
        lock = _paths_to_locks.get(path)
        if lock is None:
            _paths_to_locks[path] = lock = _FileLock(path)
    return lock
def lock_file ( path ) : with _paths_lock : lock = _paths_to_locks . get ( path ) if lock is None : _paths_to_locks [ path ] = lock = _FileLock ( path ) return lock
File based lock on ``path``.

    Creates a file based lock. When acquired, other processes or threads are
    prevented from acquiring the same lock until it is released.