Your IP : 3.149.251.22


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/filelock/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/filelock/__pycache__/_api.cpython-311.pyc

�

��bgT.���ddlmZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZdd	lmZer"ddlZdd
lmZejdkrddlmZnddlmZejd
��ZGd�d��ZeGd�d����ZGd�dee
��Z Gd�deej!��Z"ddgZ#dS)�)�annotationsN)�ABC�abstractmethod)�	dataclass)�local)�
TYPE_CHECKING�Any�ClassVar)�WeakValueDictionary�)�Timeout)�
TracebackType)��)�Self�filelockc�*�eZdZdZdd�Zdd�Zdd�ZdS)�AcquireReturnProxyzDA context aware object that will release the lock file when exiting.�lock�BaseFileLock�return�Nonec��||_dS�N�r)�selfrs  �^/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/filelock/_api.py�__init__zAcquireReturnProxy.__init__#s
����	�	�	�c��|jSrr�rs r�	__enter__zAcquireReturnProxy.__enter__&s
���y�r�exc_type�type[BaseException] | None�	exc_value�BaseException | None�	traceback�TracebackType | Nonec�8�|j���dSr)r�release�rr#r%r's    r�__exit__zAcquireReturnProxy.__exit__)s��	
�	�������rN)rrrr)rr�r#r$r%r&r'r(rr)�__name__�
__module__�__qualname__�__doc__rr"r,�rrrr sV������N�N��������������rrc�N�eZdZUdZded<ded<ded<dZd	ed
<dZded<dS)
�FileLockContextzBA dataclass which holds the context for a ``BaseFileLock`` object.�str�	lock_file�float�timeout�int�modeNz
int | None�lock_file_fdr�lock_counter)r.r/r0r1�__annotations__r;r<r2rrr4r42s_�������L�L��N�N�N��N�N�N��I�I�I� $�L�#�#�#�#��L������rr4c��eZdZdZdS)�ThreadLocalFileContextz8A thread local version of the ``FileLockContext`` class.N)r.r/r0r1r2rrr?r?Is������B�B�B�Brr?c�r��eZdZUdZe��Zded<			d9dd�d:�fd�Z			d9dd�d;d�Zd<d�Z	e
d<d���Ze
d=d���Ze
d>d���Z
e
jd?d ���Z
ed@d!���Zed@d"���Ze
d<d#���Ze
dAd$���Z		dBd%dd'�dCd-�ZdDdEd/�ZdFd0�ZdGd7�Zd@d8�Z�xZS)Hrz+Abstract base class for a file lock object.z0ClassVar[WeakValueDictionary[str, BaseFileLock]]�
_instances����TF)�is_singletonr6�str | os.PathLike[str]r8r7r:r9�thread_local�boolrD�kwargs�dict[str, Any]rrc���|s!t���|��S|j�t	|����}|s8t���|��}||jt	|��<|S)zYCreate a new lock object or if specified return the singleton instance for the lock file.)�super�__new__rA�getr5)	�clsr6r8r:rFrDrH�instance�	__class__s	        �rrLzBaseFileLock.__new__Rsr����	(��7�7�?�?�3�'�'�'��>�%�%�c�)�n�n�5�5���	6��w�w���s�+�+�H�-5�C�N�3�y�>�>�*��rrc��||_||_tj|��||d�}|rtnt
di|��|_dS)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.
        :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.
        )r6r8r:Nr2)�_is_thread_local�
_is_singleton�os�fspathr?r4�_context)rr6r8r:rFrDrHs       rrzBaseFileLock.__init__gs`��.!-���)���
��9�-�-���"
�"
��
+f�L�*e�*@�*@�Ve�)p�)p�io�)p�)p��
�
�
rc��|jS)z>:return: a flag indicating if this lock is thread local or not)rRr!s r�is_thread_localzBaseFileLock.is_thread_local�s���$�$rc��|jS)z;:return: a flag indicating if this lock is singleton or not)rSr!s rrDzBaseFileLock.is_singleton�s
���!�!rr5c��|jjS)z:return: path to the lock file)rVr6r!s rr6zBaseFileLock.lock_file�s���}�&�&rc��|jjS)za
        :return: the default timeout value, in seconds

        .. versionadded:: 2.0.0
        )rVr8r!s rr8zBaseFileLock.timeout�s���}�$�$r�value�float | strc�8�t|��|j_dS)zd
        Change the default timeout value.

        :param value: the new value, in seconds
        N)r7rVr8)rr\s  rr8zBaseFileLock.timeout�s��!&�e����
���rc��t�)zjIf the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file.��NotImplementedErrorr!s r�_acquirezBaseFileLock._acquire��
��"�!rc��t�)z>Releases the lock and sets self._context.lock_file_fd to None.r`r!s r�_releasezBaseFileLock._release�rcrc��|jjduS)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)rVr;r!s r�	is_lockedzBaseFileLock.is_locked�s���}�)��5�5rc��|jjS)zP:return: The number of times this lock has been acquired (but not yet released).)rVr<r!s rr<zBaseFileLock.lock_counter�s���}�)�)rN皙�����?)�poll_intervall�blocking�float | None�
poll_intervalrjrkrc��|�|jj}|� d}tj|td���|}|jxjdz
c_t
|��}|j}tj	��}		|j
s0t�d||��|�
��|j
rt�d||��n�|d	ur+t�d
||��t|���d|cxkrtj	��|z
kr.nn+t�d||��t|���d
}t�||||��tj|����n6#t $r)t#d|jjdz
��|j_�wxYwt%|���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 %szLock %s acquired on %sFz+Failed to immediately acquire lock %s on %srz"Timeout on acquiring lock %s on %sz2Lock %s not acquired on %s, waiting %s seconds ...r)rVr8�warnings�warn�DeprecationWarningr<�idr6�time�perf_counterrg�_LOGGER�debugrbr
�sleep�
BaseException�maxr)	rr8rmrjrk�msg�lock_id�
lock_filename�
start_times	         r�acquirezBaseFileLock.acquire�s���P�?��m�+�G��%�?�C��M�#�1�a�@�@�@�@�*�M�	
�
�"�"�a�'�"�"��T�(�(����
��&�(�(�
�	�
*��~�$��M�M�"G��R_�`�`�`��M�M�O�O�O��>���M�M�":�G�]�S�S�S���u�$�$��M�M�"O�QX�Zg�h�h�h�!�-�0�0�0���B�B�B�B�$�"3�"5�"5�
�"B�B�B�B�B�B��M�M�"F��Q^�_�_�_�!�-�0�0�0�J���
�
�c�7�M�=�I�I�I��
�=�)�)�)�
*����	�	�	�),�Q��
�0J�Q�0N�)O�)O�D�M�&��	����"�t�,�,�,�,s
�0DF�3F3�forcec�F�|jr�|jxjdzc_|jjdks|rrt|��|j}}t
�d||��|���d|j_t
�d||��dSdSdS)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rz#Attempting to release lock %s on %szLock %s released on %sN)rgrVr<rtr6rwrxre)rr�r}r~s    rr*zBaseFileLock.releases����>�		P��M�&�&�!�+�&�&��}�)�Q�.�.�%�.�)+�D���4�>����
�
�C�W�m�\�\�\��
�
����-.��
�*��
�
�6���O�O�O�O�O�		P�		P�/�.rc�.�|���|S)zE
        Acquire the lock.

        :return: the lock object
        )r�r!s rr"zBaseFileLock.__enter__#s��	
�������rr#r$r%r&r'r(c�.�|���dS)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    rr,zBaseFileLock.__exit__,s��	
�������rc�2�|�d���dS)z'Called when the lock object is deleted.T)r�Nr�r!s r�__del__zBaseFileLock.__del__;s�����4�� � � � � r)rBrCT)r6rEr8r7r:r9rFrGrDrGrHrIrr)r6rEr8r7r:r9rFrGrDrGrr)rrG)rr5)rr7)r\r]rr)rr)rr9)Nri)
r8rlrmr7rjrlrkrGrr)F)r�rGrr)rrr-)r.r/r0r1rrAr=rLrrX�propertyrDr6r8�setterrrbrergr<r�r*r"r,r��
__classcell__)rPs@rrrMsd��������5�5�CV�CV�CX�CX�J�X�X�X�X�
��!��#���������0��!�!q�#�!q�!q�!q�!q�!q�!q�F%�%�%�%��"�"�"��X�"��'�'�'��X�'��%�%�%��X�%�
�^�-�-�-��^�-��"�"�"��^�"��"�"�"��^�"��	6�	6�	6��X�	6��*�*�*��X�*�!%�#�J-�
(,��
J-�J-�J-�J-�J-�J-�XP�P�P�P�P�$����
�
�
�
�!�!�!�!�!�!�!�!rr)$�
__future__r�
contextlib�loggingrTrurq�abcrr�dataclassesr�	threadingr�typingrr	r
�weakrefr�_errorr
�sys�typesr�version_infor�typing_extensions�	getLoggerrwrr4r?�ContextDecoratorr�__all__r2rr�<module>r�s��"�"�"�"�"�"���������	�	�	�	���������#�#�#�#�#�#�#�#�!�!�!�!�!�!�������/�/�/�/�/�/�/�/�/�/�'�'�'�'�'�'��������+��J�J�J�#�#�#�#�#�#�
��7�"�"��������*�*�*�*�*�*��'�
�J�
'�
'����������$�����������,C�C�C�C�C�_�e�C�C�C�p!�p!�p!�p!�p!�3�
�3�p!�p!�p!�h�����r

?>