§
    ´¯¸j6  ã                   óº   — d Z ddlZddl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
 G d„ de¦  «        ZdS )aÖ  Exceptions raised when acquiring, holding, or releasing a lock fails.

Hierarchy::

    BaseLockException
      LockException
        AlreadyLocked
        LockLostError
        FileToLarge  (deprecated, never raised)

`BaseLockException` is the shared base and is rarely raised directly;
catch `LockException` to handle any locking failure, `AlreadyLocked` to
handle contention specifically, or `LockLostError` to handle a
distributed lock that was revoked while held.
é    Né   )Útypesc            	       ó  — e Zd ZU dZdZej        ed<   	 dZe	dz  ed<   dZ
e	dz  ed<   	 ddœdej        d	ej        ez  ej        z  dz  d
ej        ddfd„Zdeed          eej        df         ee	ej        f         f         fd„Zdd„ZdS )ÚBaseLockExceptional  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.
    - `fh_name`: the name of that file as a plain string, when the
        handle had one. `None` otherwise.
    - `strerror`: the OS error message, when the failure came from a
        system call. `None` otherwise.

    Instances pickle, so they survive the trip out of a
    `multiprocessing` worker back to the parent process. An open file
    object cannot be pickled, so `fh` is dropped (replaced by `None`)
    during pickling; `fh_name` still identifies the file afterwards, and
    an integer file descriptor is kept as-is. This applies recursively
    when one lock exception wraps another in its ``args``.
    `copy.deepcopy` behaves like pickling and drops the handle too,
    while `copy.copy` keeps `fh` shared with the original, since a
    shallow copy never leaves the process where the handle is valid.

    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_name)ÚfhÚargsr
   ÚkwargsÚreturnc                ó�  — || _         d}t          j        t          ¦  «        5  t	          |dd¦  «        }ddd¦  «         n# 1 swxY w Y   t          |t          ¦  «        r|nd| _        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.
        NÚnamer   )r
   Ú
contextlibÚsuppressÚ	ExceptionÚgetattrÚ
isinstanceÚstrr	   Úlenr   Ú__init__)Úselfr
   r   r   r   s        úf/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/portalocker/exceptions.pyr   zBaseLockException.__init__Q   s  € ð. ˆŒð
  ˆÝÔ ¥Ñ+Ô+ð 	-ð 	-Ý˜2˜v tÑ,Ô,ˆDð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-å)¨$µÑ4Ô4Ð>�t�t¸$ˆŒõ �4‰yŒy˜1Š}ˆ}¥¨D°¬GµSÑ!9Ô!9ˆ}õ ��Q”‰LŒLˆLàð 	Œõ
 	Ô˜4Ð' $Ð'Ð'Ð'Ð'Ð'Ð's   £AÁAÁA.c                 ó²   — t          | j        ¦  «        }|                     d¦  «        � t          |d         t          ¦  «        sd|d<   | j        | j        |fS )a*  Pickle without the filehandle, which cannot be pickled.

        `BaseException.__reduce__` includes the full instance ``__dict__``
        in the pickle payload (and bypasses ``__getstate__``, which is
        why this override targets ``__reduce__`` itself). With an open
        file object on `fh` that made every lock exception unpicklable,
        so a `multiprocessing` worker hitting contention crashed the
        result pipe with a ``MaybeEncodingError`` instead of delivering
        `AlreadyLocked` to the parent.

        Returns:
            The standard ``(callable, args, state)`` reduction triple:
            the class, the ``args`` tuple, and a copy of the instance
            dict in which a non-integer `fh` is replaced by `None`. An
            integer file descriptor pickles fine and is kept, and
            `fh_name` keeps identifying the file either way. Exceptions
            nested inside ``args`` are reduced recursively by pickle
            itself, so a wrapped lock exception sheds its own handle the
            same way.
        r
   N)ÚdictÚ__dict__Úgetr   ÚintÚ	__class__r   )r   Ústates     r   Ú
__reduce__zBaseLockException.__reduce__x   sP   € õ6 (,¨D¬MÑ':Ô':ˆØ�9Š9�T‰?Œ?Ð&­z¸%À¼+ÅsÑ/KÔ/KÐ&ØˆE�$‰KØ” ¤	¨5Ð1Ð1ó    c                 óš   — | j                              | j         ¦  «        }| j        |_        |j                             | j        ¦  «         |S )aŸ  Shallow-copy the exception, keeping the filehandle.

        `copy.copy` falls back to ``__reduce_ex__`` when no ``__copy__``
        is defined, and the pickle reduction above deliberately drops
        `fh`. That is right for pickling and for `copy.deepcopy`, where
        the handle would have to be serialised or duplicated, but a
        shallow copy stays inside the process where the handle is still
        perfectly usable, so dropping it there would lose information
        for no safety gain. This override keeps `fh` shared between the
        original and the copy, which is exactly what a shallow copy
        means.

        Returns:
            A new instance of the same class with the same ``args`` and
            a shallow copy of the instance attributes, `fh` included.
            ``__init__`` is bypassed, so copying a deprecated subclass
            does not re-emit its construction warning.
        )r   Ú__new__r   r   Úupdate)r   Únew_exceptions     r   Ú__copy__zBaseLockException.__copy__˜   sK   € ð& ,0¬>×+AÒ+AØŒNñ,
ô ,
ˆð "œYˆÔØÔ×%Ò% d¤mÑ4Ô4Ð4ØÐr"   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚtypingÚFinalÚ__annotations__r   r   r	   ÚAnyr   ÚIOr   Ú	HasFilenor   ÚtupleÚtyper   r!   r'   © r"   r   r   r      s)  € € € € € € ð"ð "ðH !"€K�”Ð!Ð!Ñ!ðð  €Hˆc�D‰jÐÐÑà€GˆS�4‰ZÐÐÑðð 7;ð%(ð %(ð %(àŒzð%(ð ŒH�s‰N˜Uœ_Ñ,¨tÑ3ð%(ð ”*ð	%(ð
 
ð%(ð %(ð %(ð %(ðN2à	ØÐ Ô!ØˆfŒj˜#ˆoÔØˆS�&”*ˆ_Ôð	ô
ð2ð 2ð 2ð 2ð@ð ð ð ð ð r"   r   c                   ó   — e Zd ZdZdS )ÚLockExceptionar  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` derives from it, so `except LockException` also
    catches contention (as does the deprecated, never-raised
    `FileToLarge`).

    .. 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. The first
        positional argument on POSIX stays the original `OSError`, where
        Windows passes the `LOCK_FAILED` code. Previously, `str(exc)` on
        POSIX returned the bare underlying `OSError` text; it now
        returns the 2-argument exception repr instead, for example
        ``(BlockingIOError(11, 'Resource temporarily unavailable'),
        '[Errno 11] 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+   r4   r"   r   r6   r6   ³   s   € € € € € ðð ð ð r"   r6   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)r9   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   r9   )r   r9   r   r   r   s       €r   r   zAlreadyLocked.__init__Û   s,   ø€ ð" 	�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ø$ˆŒˆˆr"   )r(   r)   r*   r+   r9   r   r.   r,   r/   r   Ú__classcell__©r   s   @r   r8   r8   Ë   s¡   ø€ € € € € € ðð ð "€J��d‘
Ð!Ð!Ñ!ðð "&ð%ð %ð %àŒzð%ð ˜$‘Jð%ð ”*ð	%ð
 
ð%ð %ð %ð %ð %ð %ð %ð %ð %ð %r"   r8   c                   óŽ   ‡ — e Zd ZU dZdZedz  ed<   	 dZedz  ed<   	 dddœdej	        dedz  dedz  dej	        ddf
ˆ fd	„Z
ˆ xZS )
ÚLockLostErroraÒ  Raised when a lock that was successfully acquired is lost again.

    `portalocker.RedisLock` keeps its lock in a live pubsub
    subscription, so the lock can be revoked from outside the holding
    process: a severed network connection, a ``CLIENT KILL`` issued by
    an administrator, or a reap by another contender that saw this
    holder stop answering pings. This exception is how that revocation
    reaches the code that thought it still held the lock. It is raised
    by `portalocker.RedisLock.ensure_held` and by the ``with`` block
    exit of a lock that was lost while the block ran; the underlying
    cause (usually a ``redis.exceptions.ConnectionError``) is attached
    as ``__cause__``.

    Beyond the `LockException` payload, instances carry `channel` and
    `holder_id` so a handler that manages several locks can tell which
    one died.

    Example:
        >>> from portalocker import exceptions
        >>> error = exceptions.LockLostError(
        ...     exceptions.LockException.LOCK_FAILED,
        ...     'lock lost',
        ...     channel='jobs',
        ...     holder_id='a1b2',
        ... )
        >>> error.channel, error.holder_id
        ('jobs', 'a1b2')

    .. versionadded:: 4.2.0
    NÚchannelÚ	holder_id)r@   rA   r   r   r   c                óV   •—  t          ¦   «         j        |i |¤Ž || _        || _        dS )a²  Initialise like `LockException`, plus record the lock identity.

        Args:
            *args: Forwarded to `LockException.__init__`.
            channel: The pubsub channel the lost lock lived on. Stored
                on `self.channel`.
            holder_id: The holder id of the lock instance that lost the
                lock. Stored on `self.holder_id`.
            **kwargs: Forwarded to `LockException.__init__`.
        N)r;   r   r@   rA   )r   r@   rA   r   r   r   s        €r   r   zLockLostError.__init__  s3   ø€ ð" 	�‰ŒÔ˜$Ð) &Ð)Ð)Ð)ØˆŒØ"ˆŒˆˆr"   )r(   r)   r*   r+   r@   r   r.   rA   r,   r/   r   r<   r=   s   @r   r?   r?   ð   sÇ   ø€ € € € € € ðð ð> €GˆS�4‰ZÐÐÑØ@à €Iˆs�T‰zÐ Ð Ñ ØEð
 #Ø $ð	#ð #ð #àŒzð#ð �t‘ð#ð ˜‘:ð	#ð
 ”*ð#ð 
ð#ð #ð #ð #ð #ð #ð #ð #ð #ð #r"   r?   c                   óD   ‡ — e Zd ZdZdej        dej        ddfˆ fd„Zˆ xZS )ÚFileToLargea¶  Deprecated and never raised; kept only for backwards compatibility.

    No version of this package has ever raised it: it was defined for a
    file-too-large failure mode that the locking backends never
    reported. Code catching it catches nothing, so it is deprecated and
    instantiating it emits a `DeprecationWarning`. Catch `LockException`
    instead.

    The misspelling in the name (`FileToLarge`, rather than
    `FileTooLarge`) is a long-standing typo in the public API. It is kept
    exactly as-is instead of being silently renamed, which would break
    `except FileToLarge` in existing code.

    .. deprecated:: 4.2.0
        Will be removed in a future major release.
    r   r   r   Nc                 ór   •— t          j        dt          d¬¦  «          t          ¦   «         j        |i |¤Ž dS )aª  Initialise like `LockException`, plus warn about deprecation.

        Args:
            *args: Forwarded to `LockException.__init__`.
            **kwargs: Forwarded to `LockException.__init__`.

        Warns:
            DeprecationWarning: Always. The warning points at the caller
                (``stacklevel=2``) so the deprecated construction site
                shows up in the report, not this initialiser.
        z‰FileToLarge is deprecated: portalocker has never raised it and it will be removed in a future major release. Catch LockException instead.é   )Ú
stacklevelN)ÚwarningsÚwarnÚDeprecationWarningr;   r   )r   r   r   r   s      €r   r   zFileToLarge.__init__>  sO   ø€ õ 	Œð%õ Øð	
ñ 	
ô 	
ð 	
ð 	�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ð)Ð)r"   )r(   r)   r*   r+   r,   r/   r   r<   r=   s   @r   rD   rD   ,  s`   ø€ € € € € ðð ð"*˜fœjð *°F´Jð *À4ð *ð *ð *ð *ð *ð *ð *ð *ð *ð *r"   rD   )r+   r   r,   rH   Ú r   r   r   r6   r8   r?   rD   r4   r"   r   ú<module>rL      s)  ððð ð  Ð Ð Ð Ø €€€Ø €€€à Ð Ð Ð Ð Ð ðXð Xð Xð Xð X˜	ñ Xô Xð Xðvð ð ð ð Ð%ñ ô ð ð0"%ð "%ð "%ð "%ð "%�Mñ "%ô "%ð "%ðJ9#ð 9#ð 9#ð 9#ð 9#�Mñ 9#ô 9#ð 9#ðx%*ð %*ð %*ð %*ð %*�-ñ %*ô %*ð %*ð %*ð %*r"   