§
    %P„j‹  ã                   óŽ   — d Z ddlZddlmZ  G d„ de¦  «        Z G d„ de¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        ZdS )a]  Exceptions raised when acquiring, holding, or releasing a lock fails.

Hierarchy::

    BaseLockException
      LockException
        AlreadyLocked
        FileToLarge

`BaseLockException` is the shared base and is rarely raised directly;
catch `LockException` to handle any locking failure, or one of its two
subclasses to handle a specific cause.
é    Né   )Útypesc            	       óš   — e Zd ZU dZdZej        ed<   	 dZe	dz  ed<   ddœdej
        dej        dz  ez  ej        z  d	ej
        d
dfd„ZdS )ÚBaseLockExceptiona£  Common base for every exception this module defines.

    Not raised directly; `LockException` and its subclasses are. Beyond
    the standard `Exception` payload, instances carry:

    - `fh`: the filehandle (or file descriptor, or file-like object)
        that was being locked when the failure happened, if one was
        available yet. `None` when the failure happened before a handle
        existed, e.g. while opening the file.
    - `strerror`: the OS error message, when the failure came from a
        system call. `None` otherwise.

    Example:
        >>> from portalocker import exceptions
        >>> try:
        ...     raise exceptions.LockException(
        ...         exceptions.LockException.LOCK_FAILED,
        ...         'Resource temporarily unavailable',
        ...     )
        ... except exceptions.LockException as exc:
        ...     exc.strerror
        'Resource temporarily unavailable'
    r   ÚLOCK_FAILEDNÚstrerror)ÚfhÚargsr	   ÚkwargsÚreturnc                óÌ   — || _         t          |¦  «        dk    r0t          |d         t          ¦  «        rt          |d         ¦  «        nd| _        t          j        | g|¢R Ž  dS )a‹  Store `fh` and extract `strerror` from `args[1]`.

        Args:
            *args: Forwarded to `Exception.__init__`. If a second
                positional argument is present and is a `str`, it becomes
                `strerror`; this mirrors the two-argument `OSError`
                convention (an error code, then a message) so a locking
                failure looks the same whether it originated on POSIX or
                on Windows.
            fh: The filehandle involved in the failure, if any. Stored
                unchanged on `self.fh`.
            **kwargs: Ignored here; accepted so that subclasses which add
                their own keyword-only arguments (e.g. `AlreadyLocked`'s
                `holder_pid`) can forward the rest of their keyword
                arguments through `super().__init__(*args, **kwargs)`
                without this initialiser rejecting them.
        r   N)r	   ÚlenÚ
isinstanceÚstrr   Ú	ExceptionÚ__init__)Úselfr	   r
   r   s       ú[/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/portalocker/exceptions.pyr   zBaseLockException.__init__8   sj   € ð. ˆŒõ �4‰yŒy˜1Š}ˆ}¥¨D°¬GµSÑ!9Ô!9ˆ}õ ��Q”‰LŒLˆLàð 	Œõ
 	Ô˜4Ð' $Ð'Ð'Ð'Ð'Ð'Ð'ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚtypingÚFinalÚ__annotations__r   r   ÚAnyr   ÚIOÚintÚ	HasFilenor   © r   r   r   r      s®   € € € € € € ðð ð0 !"€K�”Ð!Ð!Ñ!ðð  €Hˆc�D‰jÐÐÑð
 7;ð(ð (ð (àŒzð(ð ŒH�t‰O˜cÑ! E¤OÑ3ð(ð ”*ð	(ð
 
ð(ð (ð (ð (ð (ð (r   r   c                   ó   — e Zd ZdZdS )ÚLockExceptiona€  Raised when acquiring or releasing a lock fails.

    This is the general-purpose locking failure and the type to catch
    when any locking error is acceptable to handle uniformly:
    `AlreadyLocked` and `FileToLarge` both derive from it, so `except
    LockException` also catches those.

    .. versionchanged:: 4.0.0
        On POSIX, lock failures now populate `strerror` and pass the
        OS error message as the second positional argument, matching the
        contract this module already followed on Windows. Previously,
        `str(exc)` on POSIX returned the bare underlying `OSError` text;
        it now returns the 2-argument exception repr instead (for
        example ``(1, 'Resource temporarily unavailable')``). Code that
        parsed `str(exc)` on POSIX should read `.strerror` instead, which
        has held the message consistently on both platforms since 4.0.0.
    N©r   r   r   r   r!   r   r   r#   r#   X   s   € € € € € ðð ð ð r   r#   c            	       ól   ‡ — e Zd ZU dZdZedz  ed<   	 ddœdej        dedz  dej        ddfˆ fd„Z	ˆ xZ
S )	ÚAlreadyLockeda+  Raised when a lock is held elsewhere and cannot be acquired.

    This is what `Lock.acquire` raises immediately when
    `fail_when_locked=True` and the first attempt finds the lock already
    held, and also what it raises when `timeout` expires while waiting
    for the lock to become free.
    NÚ
holder_pid)r'   r
   r   r   c                óH   •—  t          ¦   «         j        |i |¤Ž || _        dS )a  Initialise like `BaseLockException`, plus record `holder_pid`.

        Args:
            *args: Forwarded to `BaseLockException.__init__`.
            holder_pid: The PID of the process already holding the lock,
                if known. Stored on `self.holder_pid`; unlike `fh` and
                `strerror`, `BaseLockException` has no equivalent
                attribute, so this is the one addition `AlreadyLocked`
                makes over its base initialiser.
            **kwargs: Forwarded to `BaseLockException.__init__`.
        N)Úsuperr   r'   )r   r'   r
   r   Ú	__class__s       €r   r   zAlreadyLocked.__init__|   s,   ø€ ð" 	�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ø$ˆŒˆˆr   )r   r   r   r   r'   r   r   r   r   r   Ú__classcell__)r*   s   @r   r&   r&   l   s¡   ø€ € € € € € ðð ð "€J��d‘
Ð!Ð!Ñ!ðð "&ð%ð %ð %àŒzð%ð ˜$‘Jð%ð ”*ð	%ð
 
ð%ð %ð %ð %ð %ð %ð %ð %ð %ð %r   r&   c                   ó   — e Zd ZdZdS )ÚFileToLargeaY  Raised when a file is too large for the locking call to handle.

    The misspelling in the name (`FileToLarge`, rather than
    `FileTooLarge`) is a long-standing typo in the public API. It is kept
    exactly as-is for backwards compatibility instead of being silently
    renamed, which would break `except FileToLarge` in existing code.
    Nr$   r!   r   r   r-   r-   ‘   s   € € € € € ðð ð ð r   r-   )	r   r   Ú r   r   r   r#   r&   r-   r!   r   r   ú<module>r/      sé   ððð ð €€€à Ð Ð Ð Ð Ð ðA(ð A(ð A(ð A(ð A(˜	ñ A(ô A(ð A(ðHð ð ð ð Ð%ñ ô ð ð("%ð "%ð "%ð "%ð "%�Mñ "%ô "%ð "%ðJð ð ð ð �-ñ ô ð ð ð r   