class_docstr: Abstract base class for a file lock object.
docstr: Create a new lock object.
  
  :param lock_file: path to the file
  :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in             the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it             to a negative value. A timeout of 0 means, that there is exactly one attempt to acquire the file lock.
  :param mode: file permissions for the lockfile
  :param thread_local: Whether this object's internal context should be thread local or not. If this is set to             ``False`` then the lock will be reentrant across threads.
  :param is_singleton: If this is set to ``True`` then only one instance of this class will be created             per lock file. This is useful if you want to use the lock object for reentrant locking without needing             to pass the same object around.
code: def __init__(  # noqa: PLR0913
      self,
      lock_file: str | os.PathLike[str],
      timeout: float = -1,
      mode: int = 0o644,
      thread_local: bool = True,  # noqa: FBT001, FBT002
      *,
      is_singleton: bool = False,
  ) -> None:
      """
          Create a new lock object.
  
          :param lock_file: path to the file
          :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in \
              the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it \
              to a negative value. A timeout of 0 means, that there is exactly one attempt to acquire the file lock.
          :param mode: file permissions for the lockfile
          :param thread_local: Whether this object's internal context should be thread local or not. If this is set to \
              ``False`` then the lock will be reentrant across threads.
          :param is_singleton: If this is set to ``True`` then only one instance of this class will be created \
              per lock file. This is useful if you want to use the lock object for reentrant locking without needing \
              to pass the same object around.
          """
      self._is_thread_local = thread_local
      self._is_singleton = is_singleton
  
      # Create the context. Note that external code should not work with the context directly  and should instead use
      # properties of this class.
      kwargs: dict[str, Any] = {
          "lock_file": os.fspath(lock_file),
          "timeout": timeout,
          "mode": mode,
      }
      self._context: FileLockContext = (
          ThreadLocalFileContext if thread_local else FileLockContext
      )(**kwargs)
  
imports: from __future__ import annotations
  import contextlib
  import logging
  import os
  import time
  import warnings
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from threading import local
  from typing import TYPE_CHECKING, Any, ClassVar
  from weakref import WeakValueDictionary
  from ._error import Timeout
label_desc: Use image node_id 2 to create a new BaseFileLock object from inherited base classes: ABC, contextlib with example: obj = BaseFileLock(lock_file, timeout, mode, thread_local)