code: 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
docs: 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.