§
    MjÀ"  ã                  óä   — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZm	Z	 d dl
mZ d dlmZ d dlmZ ddlmZ  ej        d	¦  «        Z G d
„ d¦  «        Z G d„ deej        ¦  «        ZddgZdS )é    )ÚannotationsN)ÚABCÚabstractmethod)ÚLock)ÚTracebackType)ÚAnyé   )ÚTimeoutÚfilelockc                  ó*   — e Zd ZdZdd„Zdd„Zdd„ZdS )ÚAcquireReturnProxyzDA context aware object that will release the lock file when exiting.ÚlockÚBaseFileLockÚreturnÚNonec                ó   — || _         d S ©N©r   )Úselfr   s     ú//usr/lib/python3/dist-packages/filelock/_api.pyÚ__init__zAcquireReturnProxy.__init__   s   € ØˆŒ	ˆ	ˆ	ó    c                ó   — | j         S r   r   ©r   s    r   Ú	__enter__zAcquireReturnProxy.__enter__   s
   € ØŒyÐr   Úexc_typeútype[BaseException] | NoneÚ	exc_valueúBaseException | NoneÚ	tracebackúTracebackType | Nonec                ó8   — | j                              ¦   «          d S r   )r   Úrelease©r   r   r   r    s       r   Ú__exit__zAcquireReturnProxy.__exit__   s   € ð 	Œ	×ÒÑÔÐÐÐr   N)r   r   r   r   ©r   r   ©r   r   r   r   r    r!   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r%   © r   r   r   r      sV   € € € € € ØNÐNðð ð ð ðð ð ð ðð ð ð ð ð r   r   c                  óî   — e Zd ZdZd*d+d	„Zed,d„¦   «         Zed-d„¦   «         Zej        d.d„¦   «         Ze	d/d„¦   «         Z
e	d/d„¦   «         Zed0d„¦   «         Z	 	 d1dddœd2d„Zd3d4d „Zd5d!„Zd6d(„Zd/d)„ZdS )7r   z+Abstract base class for a file lock object.éÿÿÿÿÚ	lock_fileústr | os.PathLike[Any]ÚtimeoutÚfloatr   r   c                óˆ   — t          j        |¦  «        | _        d| _        || _        t          ¦   «         | _        d| _        dS )a¨  
        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.
        Nr   )ÚosÚfspathÚ
_lock_fileÚ_lock_file_fdÚ_timeoutr   Ú_thread_lockÚ_lock_counter)r   r/   r1   s      r   r   zBaseFileLock.__init__*   sF   € õ  "œy¨Ñ3Ô3ˆŒð *.ˆÔð  'ˆŒõ #'¡&¤&ˆÔð #$ˆÔÐÐr   Ústrc                ó   — | j         S )z:return: path to the lock file)r6   r   s    r   r/   zBaseFileLock.lock_fileD   s   € ð ŒÐr   c                ó   — | j         S )za
        :return: the default timeout value, in seconds

        .. versionadded:: 2.0.0
        )r8   r   s    r   r1   zBaseFileLock.timeoutI   s   € ð Œ}Ðr   Úvalueúfloat | strc                ó.   — t          |¦  «        | _        dS )zd
        Change the default timeout value.

        :param value: the new value, in seconds
        N)r2   r8   )r   r>   s     r   r1   zBaseFileLock.timeoutR   s   € õ ˜e™œˆŒˆˆr   c                ó   — t           ‚)zbIf the file lock could be acquired, self._lock_file_fd holds the file descriptor of the lock file.©ÚNotImplementedErrorr   s    r   Ú_acquirezBaseFileLock._acquire[   ó
   € õ "Ð!r   c                ó   — t           ‚)z6Releases the lock and sets self._lock_file_fd to None.rB   r   s    r   Ú_releasezBaseFileLock._release`   rE   r   Úboolc                ó   — | j         duS )zÄ

        :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.
        N)r7   r   s    r   Ú	is_lockedzBaseFileLock.is_lockede   s   € ð Ô!¨Ð-Ð-r   Nçš™™™™™©?T)Úpoll_intervallÚblockingúfloat | NoneÚpoll_intervalrL   rM   r   c               ó2  — |€| j         }|� d}t          j        |t          d¬¦  «         |}| j        5  | xj        dz  c_        ddd¦  «         n# 1 swxY w Y   t          | ¦  «        }| j        }t          j	        ¦   «         }	 	 | j        5  | j
        s0t                               d||¦  «         |                      ¦   «          ddd¦  «         n# 1 swxY w Y   | j
        rt                               d||¦  «         n½|d	u r0t                               d
||¦  «         t          | j        ¦  «        ‚d|cxk    rt          j	        ¦   «         |z
  k     r3n n0t                               d||¦  «         t          | j        ¦  «        ‚d}t                               ||||¦  «         t          j        |¦  «         �Œ7nK# t           $ r> | j        5  t#          d| j        dz
  ¦  «        | _        ddd¦  «         n# 1 swxY w Y   ‚ w xY wt%          | ¬¦  «        S )a^  
        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.

        Nz+use poll_interval instead of poll_intervallé   )Ú
stacklevelr	   Tz#Attempting to acquire lock %s on %szLock %s acquired on %sFz+Failed to immediately acquire lock %s on %sr   z"Timeout on acquiring lock %s on %sz2Lock %s not acquired on %s, waiting %s seconds ...r   )r1   ÚwarningsÚwarnÚDeprecationWarningr9   r:   Úidr6   ÚtimeÚ	monotonicrJ   Ú_LOGGERÚdebugrD   r
   ÚsleepÚBaseExceptionÚmaxr   )	r   r1   rO   rL   rM   ÚmsgÚlock_idÚlock_filenameÚ
start_times	            r   ÚacquirezBaseFileLock.acquireq   s	  € ðP ˆ?Ø”lˆGàÐ%Ø?ˆCÝŒM˜#Õ1¸aÐ@Ñ@Ô@Ð@Ø*ˆMð Ôð 	$ð 	$ØÐÔ !Ñ#ÐÔð	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$õ �T‘(”(ˆØœˆÝ”^Ñ%Ô%ˆ
ð	ð.ØÔ&ð (ð (Øœ>ð (ÝŸšÐ&KÈWÐVcÑdÔdÐdØŸš™œ˜ð(ð (ð (ñ (ô (ð (ð (ð (ð (ð (ð (øøøð (ð (ð (ð (ð
 ”>ð .Ý—M’MÐ":¸GÀ]ÑSÔSÐSØØ Ð&Ð&Ý—M’MÐ"OÐQXÐZgÑhÔhÐhÝ! $¤/Ñ2Ô2Ð2Ø˜'ÐAÐAÒAÐA¥D¤NÑ$4Ô$4°zÑ$AÒAÐAÐAÐAÐAÝ—M’MÐ"FÈÐQ^Ñ_Ô_Ð_Ý! $¤/Ñ2Ô2Ð2àN�CÝ—M’M # w°¸}ÑMÔMÐMÝ”J˜}Ñ-Ô-Ð-ñ%.ð øõ ð 	ð 	ð 	ØÔ"ð Dð DÝ%(¨¨DÔ,>ÀÑ,BÑ%CÔ%C�Ô"ðDð Dð Dñ Dô Dð Dð Dð Dð Dð Dð Døøøð Dð Dð Dð Dàð	øøøõ " tÐ,Ñ,Ô,Ð,sf   ³AÁAÁAÂF> Â8CÃF> ÃCÃF> ÃCÃC$F> Æ>HÇG9Ç-HÇ9G=	Ç=HÈ G=	ÈHFÚforcec                ó`  — | j         5  | j        r†| xj        dz  c_        | j        dk    s|rit          | ¦  «        | j        }}t
                               d||¦  «         |                      ¦   «          d| _        t
                               d||¦  «         ddd¦  «         dS # 1 swxY w Y   dS )a*  
        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/
        r	   r   z#Attempting to release lock %s on %szLock %s released on %sN)r9   rJ   r:   rV   r6   rY   rZ   rG   )r   rc   r_   r`   s       r   r#   zBaseFileLock.releaseÂ   s  € ð Ôð 	Tð 	TàŒ~ð 	TØÐ"Ô" aÑ'Ð"Ô"àÔ%¨Ò*Ð*¨eÐ*Ý-/°©X¬X°t´˜]�Gå—M’MÐ"GÈÐR_Ñ`Ô`Ð`Ø—M’M‘O”O�OØ)*�DÔ&Ý—M’MÐ":¸GÀ]ÑSÔSÐSð	Tð 	Tð 	Tñ 	Tô 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tøøøð 	Tð 	Tð 	Tð 	Tð 	Tð 	Ts   ˆBB#Â#B'Â*B'c                ó.   — |                       ¦   «          | S )zE
        Acquire the lock.

        :return: the lock object
        )rb   r   s    r   r   zBaseFileLock.__enter__Ö   s   € ð 	�Š‰ŒˆØˆr   r   r   r   r   r    r!   c                ó.   — |                       ¦   «          dS )zÎ
        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
        N©r#   r$   s       r   r%   zBaseFileLock.__exit__ß   s   € ð 	�Š‰Œˆˆˆr   c                ó2   — |                       d¬¦  «         dS )z'Called when the lock object is deleted.T)rc   Nrg   r   s    r   Ú__del__zBaseFileLock.__del__î   s   € à�Š˜4ˆÑ Ô Ð Ð Ð r   )r.   )r/   r0   r1   r2   r   r   )r   r;   )r   r2   )r>   r?   r   r   )r   r   )r   rH   )NrK   )
r1   rN   rO   r2   rL   rN   rM   rH   r   r   )F)rc   rH   r   r   r&   r'   )r(   r)   r*   r+   r   Úpropertyr/   r1   Úsetterr   rD   rG   rJ   rb   r#   r   r%   ri   r,   r   r   r   r   '   sŠ  € € € € € Ø5Ð5ð$ð $ð $ð $ð $ð4 ðð ð ñ „Xðð ðð ð ñ „Xðð „^ð%ð %ð %ñ „^ð%ð ð"ð "ð "ñ „^ð"ð ð"ð "ð "ñ „^ð"ð ð	.ð 	.ð 	.ñ „Xð	.ð !%Ø#ðO-ð
 (,ØðO-ð O-ð O-ð O-ð O-ð O-ðbTð Tð Tð Tð Tð(ð ð ð ðð ð ð ð!ð !ð !ð !ð !ð !r   r   )Ú
__future__r   Ú
contextlibÚloggingr4   rW   rS   Úabcr   r   Ú	threadingr   Útypesr   Útypingr   Ú_errorr
   Ú	getLoggerrY   r   ÚContextDecoratorr   Ú__all__r,   r   r   ú<module>rw      s,  ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø €€€Ø 	€	€	€	Ø €€€Ø €€€Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð à
ˆ'Ô
˜JÑ
'Ô
'€ðð ð ð ð ñ ô ð ð$I!ð I!ð I!ð I!ð I!�3˜
Ô3ñ I!ô I!ð I!ðZ Øð€€€r   