pydoc > filelock

Help on package filelock:

NAME
    filelock - A platform independent file lock that supports the with-statement.

DESCRIPTION
    .. autodata:: filelock.__version__
       :no-value:

PACKAGE CONTENTS
    _api
    _error
    _soft
    _unix
    _util
    _windows
    version

CLASSES
    abc.ABC(builtins.object)
        filelock._api.BaseFileLock(abc.ABC, contextlib.ContextDecorator)
            filelock._soft.SoftFileLock
            filelock._unix.UnixFileLock
            filelock._windows.WindowsFileLock
    builtins.TimeoutError(builtins.OSError)
        filelock._error.Timeout
    builtins.object
        filelock._api.AcquireReturnProxy
    contextlib.ContextDecorator(builtins.object)
        filelock._api.BaseFileLock(abc.ABC, contextlib.ContextDecorator)
            filelock._soft.SoftFileLock
            filelock._unix.UnixFileLock
            filelock._windows.WindowsFileLock

    class AcquireReturnProxy(builtins.object)
     |  AcquireReturnProxy(lock: 'BaseFileLock') -> 'None'
     |
     |  A context aware object that will release the lock file when exiting.
     |
     |  Methods defined here:
     |
     |  __enter__(self) -> 'BaseFileLock'
     |
     |  __exit__(self, exc_type: 'type[BaseException] | None', exc_value: 'BaseException | None', traceback: 'TracebackType | None') -> 'None'
     |
     |  __init__(self, lock: 'BaseFileLock') -> 'None'
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables
     |
     |  __weakref__
     |      list of weak references to the object

    class BaseFileLock(abc.ABC, contextlib.ContextDecorator)
     |  BaseFileLock(lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |
     |  Abstract base class for a file lock object.
     |
     |  Method resolution order:
     |      BaseFileLock
     |      abc.ABC
     |      contextlib.ContextDecorator
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __del__(self) -> 'None'
     |      Called when the lock object is deleted.
     |
     |  __enter__(self) -> 'Self'
     |      Acquire the lock.
     |
     |      :return: the lock object
     |
     |  __exit__(self, exc_type: 'type[BaseException] | None', exc_value: 'BaseException | None', traceback: 'TracebackType | None') -> 'None'
     |      Release the lock.
     |
     |      :param exc_type: the exception type if raised
     |      :param exc_value: the exception value if raised
     |      :param traceback: the exception traceback if raised
     |
     |  __init__(self, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, 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.
     |
     |  acquire(self, timeout: 'float | None' = None, poll_interval: 'float' = 0.05, *, poll_intervall: 'float | None' = None, blocking: 'bool' = True) -> 'AcquireReturnProxy'
     |      Try to acquire the file lock.
     |
     |      :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and
     |       if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired
     |      :param poll_interval: interval of trying to acquire the lock file
     |      :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead
     |      :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
     |       first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
     |      :raises Timeout: if fails to acquire lock within the timeout period
     |      :return: a context object that will unlock the file when the context is exited
     |
     |      .. code-block:: python
     |
     |          # You can use this method in the context manager (recommended)
     |          with lock.acquire():
     |              pass
     |
     |          # Or use an equivalent try-finally construct:
     |          lock.acquire()
     |          try:
     |              pass
     |          finally:
     |              lock.release()
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This method returns now a *proxy* object instead of *self*,
     |          so that it can be used in a with statement without side effects.
     |
     |  is_thread_local(self) -> 'bool'
     |      :return: a flag indicating if this lock is thread local or not
     |
     |  release(self, force: 'bool' = False) -> 'None'
     |      Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also
     |      note, that the lock file itself is not automatically deleted.
     |
     |      :param force: If true, the lock counter is ignored and the lock is released in every case/
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |      Create a new lock object or if specified return the singleton instance for the lock file.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties defined here:
     |
     |  is_locked
     |      :return: A boolean indicating if the lock file is holding the lock currently.
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This was previously a method and is now a property.
     |
     |  is_singleton
     |      :return: a flag indicating if this lock is singleton or not
     |
     |  lock_counter
     |      :return: The number of times this lock has been acquired (but not yet released).
     |
     |  lock_file
     |      :return: path to the lock file
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables
     |
     |  __weakref__
     |      list of weak references to the object
     |
     |  timeout
     |      :return: the default timeout value, in seconds
     |
     |      .. versionadded:: 2.0.0
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __abstractmethods__ = frozenset({'_acquire', '_release'})
     |
     |  __annotations__ = {'_instances': 'ClassVar[WeakValueDictionary[str, Ba...
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from contextlib.ContextDecorator:
     |
     |  __call__(self, func)
     |      Call self as a function.

    FileLock = class UnixFileLock(filelock._api.BaseFileLock)
     |  FileLock(lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |
     |  Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.
     |
     |  Method resolution order:
     |      UnixFileLock
     |      filelock._api.BaseFileLock
     |      abc.ABC
     |      contextlib.ContextDecorator
     |      builtins.object
     |
     |  Data and other attributes defined here:
     |
     |  __abstractmethods__ = frozenset()
     |
     |  __annotations__ = {}
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from filelock._api.BaseFileLock:
     |
     |  __del__(self) -> 'None'
     |      Called when the lock object is deleted.
     |
     |  __enter__(self) -> 'Self'
     |      Acquire the lock.
     |
     |      :return: the lock object
     |
     |  __exit__(self, exc_type: 'type[BaseException] | None', exc_value: 'BaseException | None', traceback: 'TracebackType | None') -> 'None'
     |      Release the lock.
     |
     |      :param exc_type: the exception type if raised
     |      :param exc_value: the exception value if raised
     |      :param traceback: the exception traceback if raised
     |
     |  __init__(self, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, 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.
     |
     |  acquire(self, timeout: 'float | None' = None, poll_interval: 'float' = 0.05, *, poll_intervall: 'float | None' = None, blocking: 'bool' = True) -> 'AcquireReturnProxy'
     |      Try to acquire the file lock.
     |
     |      :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and
     |       if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired
     |      :param poll_interval: interval of trying to acquire the lock file
     |      :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead
     |      :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
     |       first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
     |      :raises Timeout: if fails to acquire lock within the timeout period
     |      :return: a context object that will unlock the file when the context is exited
     |
     |      .. code-block:: python
     |
     |          # You can use this method in the context manager (recommended)
     |          with lock.acquire():
     |              pass
     |
     |          # Or use an equivalent try-finally construct:
     |          lock.acquire()
     |          try:
     |              pass
     |          finally:
     |              lock.release()
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This method returns now a *proxy* object instead of *self*,
     |          so that it can be used in a with statement without side effects.
     |
     |  is_thread_local(self) -> 'bool'
     |      :return: a flag indicating if this lock is thread local or not
     |
     |  release(self, force: 'bool' = False) -> 'None'
     |      Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also
     |      note, that the lock file itself is not automatically deleted.
     |
     |      :param force: If true, the lock counter is ignored and the lock is released in every case/
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from filelock._api.BaseFileLock:
     |
     |  __new__(cls, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |      Create a new lock object or if specified return the singleton instance for the lock file.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties inherited from filelock._api.BaseFileLock:
     |
     |  is_locked
     |      :return: A boolean indicating if the lock file is holding the lock currently.
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This was previously a method and is now a property.
     |
     |  is_singleton
     |      :return: a flag indicating if this lock is singleton or not
     |
     |  lock_counter
     |      :return: The number of times this lock has been acquired (but not yet released).
     |
     |  lock_file
     |      :return: path to the lock file
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from filelock._api.BaseFileLock:
     |
     |  __dict__
     |      dictionary for instance variables
     |
     |  __weakref__
     |      list of weak references to the object
     |
     |  timeout
     |      :return: the default timeout value, in seconds
     |
     |      .. versionadded:: 2.0.0
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from contextlib.ContextDecorator:
     |
     |  __call__(self, func)
     |      Call self as a function.

    class SoftFileLock(filelock._api.BaseFileLock)
     |  SoftFileLock(lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |
     |  Simply watches the existence of the lock file.
     |
     |  Method resolution order:
     |      SoftFileLock
     |      filelock._api.BaseFileLock
     |      abc.ABC
     |      contextlib.ContextDecorator
     |      builtins.object
     |
     |  Data and other attributes defined here:
     |
     |  __abstractmethods__ = frozenset()
     |
     |  __annotations__ = {}
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from filelock._api.BaseFileLock:
     |
     |  __del__(self) -> 'None'
     |      Called when the lock object is deleted.
     |
     |  __enter__(self) -> 'Self'
     |      Acquire the lock.
     |
     |      :return: the lock object
     |
     |  __exit__(self, exc_type: 'type[BaseException] | None', exc_value: 'BaseException | None', traceback: 'TracebackType | None') -> 'None'
     |      Release the lock.
     |
     |      :param exc_type: the exception type if raised
     |      :param exc_value: the exception value if raised
     |      :param traceback: the exception traceback if raised
     |
     |  __init__(self, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, 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.
     |
     |  acquire(self, timeout: 'float | None' = None, poll_interval: 'float' = 0.05, *, poll_intervall: 'float | None' = None, blocking: 'bool' = True) -> 'AcquireReturnProxy'
     |      Try to acquire the file lock.
     |
     |      :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and
     |       if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired
     |      :param poll_interval: interval of trying to acquire the lock file
     |      :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead
     |      :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
     |       first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
     |      :raises Timeout: if fails to acquire lock within the timeout period
     |      :return: a context object that will unlock the file when the context is exited
     |
     |      .. code-block:: python
     |
     |          # You can use this method in the context manager (recommended)
     |          with lock.acquire():
     |              pass
     |
     |          # Or use an equivalent try-finally construct:
     |          lock.acquire()
     |          try:
     |              pass
     |          finally:
     |              lock.release()
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This method returns now a *proxy* object instead of *self*,
     |          so that it can be used in a with statement without side effects.
     |
     |  is_thread_local(self) -> 'bool'
     |      :return: a flag indicating if this lock is thread local or not
     |
     |  release(self, force: 'bool' = False) -> 'None'
     |      Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also
     |      note, that the lock file itself is not automatically deleted.
     |
     |      :param force: If true, the lock counter is ignored and the lock is released in every case/
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from filelock._api.BaseFileLock:
     |
     |  __new__(cls, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |      Create a new lock object or if specified return the singleton instance for the lock file.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties inherited from filelock._api.BaseFileLock:
     |
     |  is_locked
     |      :return: A boolean indicating if the lock file is holding the lock currently.
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This was previously a method and is now a property.
     |
     |  is_singleton
     |      :return: a flag indicating if this lock is singleton or not
     |
     |  lock_counter
     |      :return: The number of times this lock has been acquired (but not yet released).
     |
     |  lock_file
     |      :return: path to the lock file
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from filelock._api.BaseFileLock:
     |
     |  __dict__
     |      dictionary for instance variables
     |
     |  __weakref__
     |      list of weak references to the object
     |
     |  timeout
     |      :return: the default timeout value, in seconds
     |
     |      .. versionadded:: 2.0.0
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from contextlib.ContextDecorator:
     |
     |  __call__(self, func)
     |      Call self as a function.

    class Timeout(builtins.TimeoutError)
     |  Timeout(lock_file: 'str') -> 'None'
     |
     |  Raised when the lock could not be acquired in *timeout* seconds.
     |
     |  Method resolution order:
     |      Timeout
     |      builtins.TimeoutError
     |      builtins.OSError
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __init__(self, lock_file: 'str') -> 'None'
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __reduce__(self) -> 'str | tuple[Any, ...]'
     |      Helper for pickle.
     |
     |  __repr__(self) -> 'str'
     |      Return repr(self).
     |
     |  __str__(self) -> 'str'
     |      Return str(self).
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties defined here:
     |
     |  lock_file
     |      :return: The path of the file lock.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.OSError:
     |
     |  __new__(*args, **kwargs) class method of builtins.OSError
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.OSError:
     |
     |  characters_written
     |
     |  errno
     |      POSIX exception code
     |
     |  filename
     |      exception filename
     |
     |  filename2
     |      second exception filename
     |
     |  strerror
     |      exception strerror
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  add_note(...)
     |      Exception.add_note(note) --
     |      add a note to the exception
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class UnixFileLock(filelock._api.BaseFileLock)
     |  UnixFileLock(lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |
     |  Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.
     |
     |  Method resolution order:
     |      UnixFileLock
     |      filelock._api.BaseFileLock
     |      abc.ABC
     |      contextlib.ContextDecorator
     |      builtins.object
     |
     |  Data and other attributes defined here:
     |
     |  __abstractmethods__ = frozenset()
     |
     |  __annotations__ = {}
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from filelock._api.BaseFileLock:
     |
     |  __del__(self) -> 'None'
     |      Called when the lock object is deleted.
     |
     |  __enter__(self) -> 'Self'
     |      Acquire the lock.
     |
     |      :return: the lock object
     |
     |  __exit__(self, exc_type: 'type[BaseException] | None', exc_value: 'BaseException | None', traceback: 'TracebackType | None') -> 'None'
     |      Release the lock.
     |
     |      :param exc_type: the exception type if raised
     |      :param exc_value: the exception value if raised
     |      :param traceback: the exception traceback if raised
     |
     |  __init__(self, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, 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.
     |
     |  acquire(self, timeout: 'float | None' = None, poll_interval: 'float' = 0.05, *, poll_intervall: 'float | None' = None, blocking: 'bool' = True) -> 'AcquireReturnProxy'
     |      Try to acquire the file lock.
     |
     |      :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and
     |       if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired
     |      :param poll_interval: interval of trying to acquire the lock file
     |      :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead
     |      :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
     |       first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
     |      :raises Timeout: if fails to acquire lock within the timeout period
     |      :return: a context object that will unlock the file when the context is exited
     |
     |      .. code-block:: python
     |
     |          # You can use this method in the context manager (recommended)
     |          with lock.acquire():
     |              pass
     |
     |          # Or use an equivalent try-finally construct:
     |          lock.acquire()
     |          try:
     |              pass
     |          finally:
     |              lock.release()
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This method returns now a *proxy* object instead of *self*,
     |          so that it can be used in a with statement without side effects.
     |
     |  is_thread_local(self) -> 'bool'
     |      :return: a flag indicating if this lock is thread local or not
     |
     |  release(self, force: 'bool' = False) -> 'None'
     |      Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also
     |      note, that the lock file itself is not automatically deleted.
     |
     |      :param force: If true, the lock counter is ignored and the lock is released in every case/
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from filelock._api.BaseFileLock:
     |
     |  __new__(cls, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |      Create a new lock object or if specified return the singleton instance for the lock file.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties inherited from filelock._api.BaseFileLock:
     |
     |  is_locked
     |      :return: A boolean indicating if the lock file is holding the lock currently.
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This was previously a method and is now a property.
     |
     |  is_singleton
     |      :return: a flag indicating if this lock is singleton or not
     |
     |  lock_counter
     |      :return: The number of times this lock has been acquired (but not yet released).
     |
     |  lock_file
     |      :return: path to the lock file
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from filelock._api.BaseFileLock:
     |
     |  __dict__
     |      dictionary for instance variables
     |
     |  __weakref__
     |      list of weak references to the object
     |
     |  timeout
     |      :return: the default timeout value, in seconds
     |
     |      .. versionadded:: 2.0.0
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from contextlib.ContextDecorator:
     |
     |  __call__(self, func)
     |      Call self as a function.

    class WindowsFileLock(filelock._api.BaseFileLock)
     |  WindowsFileLock(lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |
     |  Uses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.
     |
     |  Method resolution order:
     |      WindowsFileLock
     |      filelock._api.BaseFileLock
     |      abc.ABC
     |      contextlib.ContextDecorator
     |      builtins.object
     |
     |  Data and other attributes defined here:
     |
     |  __abstractmethods__ = frozenset()
     |
     |  __annotations__ = {}
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from filelock._api.BaseFileLock:
     |
     |  __del__(self) -> 'None'
     |      Called when the lock object is deleted.
     |
     |  __enter__(self) -> 'Self'
     |      Acquire the lock.
     |
     |      :return: the lock object
     |
     |  __exit__(self, exc_type: 'type[BaseException] | None', exc_value: 'BaseException | None', traceback: 'TracebackType | None') -> 'None'
     |      Release the lock.
     |
     |      :param exc_type: the exception type if raised
     |      :param exc_value: the exception value if raised
     |      :param traceback: the exception traceback if raised
     |
     |  __init__(self, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, 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.
     |
     |  acquire(self, timeout: 'float | None' = None, poll_interval: 'float' = 0.05, *, poll_intervall: 'float | None' = None, blocking: 'bool' = True) -> 'AcquireReturnProxy'
     |      Try to acquire the file lock.
     |
     |      :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and
     |       if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired
     |      :param poll_interval: interval of trying to acquire the lock file
     |      :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead
     |      :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
     |       first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
     |      :raises Timeout: if fails to acquire lock within the timeout period
     |      :return: a context object that will unlock the file when the context is exited
     |
     |      .. code-block:: python
     |
     |          # You can use this method in the context manager (recommended)
     |          with lock.acquire():
     |              pass
     |
     |          # Or use an equivalent try-finally construct:
     |          lock.acquire()
     |          try:
     |              pass
     |          finally:
     |              lock.release()
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This method returns now a *proxy* object instead of *self*,
     |          so that it can be used in a with statement without side effects.
     |
     |  is_thread_local(self) -> 'bool'
     |      :return: a flag indicating if this lock is thread local or not
     |
     |  release(self, force: 'bool' = False) -> 'None'
     |      Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also
     |      note, that the lock file itself is not automatically deleted.
     |
     |      :param force: If true, the lock counter is ignored and the lock is released in every case/
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from filelock._api.BaseFileLock:
     |
     |  __new__(cls, lock_file: 'str | os.PathLike[str]', timeout: 'float' = -1, mode: 'int' = 420, thread_local: 'bool' = True, *, is_singleton: 'bool' = False, **kwargs: 'dict[str, Any]') -> 'Self'
     |      Create a new lock object or if specified return the singleton instance for the lock file.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties inherited from filelock._api.BaseFileLock:
     |
     |  is_locked
     |      :return: A boolean indicating if the lock file is holding the lock currently.
     |
     |      .. versionchanged:: 2.0.0
     |
     |          This was previously a method and is now a property.
     |
     |  is_singleton
     |      :return: a flag indicating if this lock is singleton or not
     |
     |  lock_counter
     |      :return: The number of times this lock has been acquired (but not yet released).
     |
     |  lock_file
     |      :return: path to the lock file
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from filelock._api.BaseFileLock:
     |
     |  __dict__
     |      dictionary for instance variables
     |
     |  __weakref__
     |      list of weak references to the object
     |
     |  timeout
     |      :return: the default timeout value, in seconds
     |
     |      .. versionadded:: 2.0.0
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from contextlib.ContextDecorator:
     |
     |  __call__(self, func)
     |      Call self as a function.

DATA
    __all__ = ['__version__', 'FileLock', 'SoftFileLock', 'Timeout', 'Unix...
    __annotations__ = {'_FileLock': 'type[BaseFileLock]', '__version__': '...

VERSION
    3.13.1

FILE
    /usr/lib/python3/dist-packages/filelock/__init__.py


filelock
NAME DESCRIPTION PACKAGE CONTENTS CLASSES
class AcquireReturnProxy(builtins.object) class BaseFileLock(abc.ABC, contextlib.ContextDecorator) class SoftFileLock(filelock._api.BaseFileLock) class Timeout(builtins.TimeoutError) class UnixFileLock(filelock._api.BaseFileLock) class WindowsFileLock(filelock._api.BaseFileLock)
DATA VERSION FILE

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 16:45 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^