PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/filelock/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/filelock/__pycache__/asyncio.cpython-312.pyc

�

���g�0���dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZmZdd	lmZdd
lmZddlmZddlmZe
r,ddlZdd
lm Z ddl!m"Z"ejFdk\rddlm$Z$nddl%m$Z$ejLd�Z'e	Gd�de��Z(Gd�de(e�Z)Gd�d�Z*Gd�de�Z+Gd�dee+��Z,Gd�dee,�Z-Gd�d ee,�Z.Gd!�d"ee,�Z/gd#�Z0y)$z1An asyncio-based implementation of the file lock.�)�annotationsN)�	dataclass)�local)�
TYPE_CHECKING�Any�Callable�NoReturn�cast�)�BaseFileLock�FileLockContext�FileLockMeta)�Timeout)�SoftFileLock)�UnixFileLock)�WindowsFileLock)�futures)�
TracebackType)��)�Self�filelockc�<�eZdZUdZdZded<dZded<dZded	<y)
�AsyncFileLockContextzGA dataclass which holds the context for a ``BaseAsyncFileLock`` object.T�bool�run_in_executorN�futures.Executor | None�executor� asyncio.AbstractEventLoop | None�loop)�__name__�
__module__�__qualname__�__doc__r�__annotations__rr ���?/opt/hc_python/lib/python3.12/site-packages/filelock/asyncio.pyrr"s+��Q�!�O�T� �)-�H�%�,�.2�D�
*�1r'rc��eZdZdZy)�AsyncThreadLocalFileContextz8A thread local version of the ``FileLockContext`` class.N�r!r"r#r$r&r'r(r*r*0s��Br'r*c�8�eZdZdZdd�Zdd�Z								dd�Zy)	�AsyncAcquireReturnProxyzDA context-aware object that will release the lock file when exiting.c��||_y�N��lock)�selfr1s  r(�__init__z AsyncAcquireReturnProxy.__init__7s	����	r'c��"K�|jS�wr/r0�r2s r(�
__aenter__z"AsyncAcquireReturnProxy.__aenter__:s�����y�y��s�
c��TK�|jj��d{���y7��wr/)r1�release�r2�exc_type�	exc_value�	tracebacks    r(�	__aexit__z!AsyncAcquireReturnProxy.__aexit__=s�����i�i���!�!�!�s�(�&�(N)r1�BaseAsyncFileLock�return�None)r?r>�r:ztype[BaseException] | Noner;zBaseException | Noner<zTracebackType | Noner?r@)r!r"r#r$r3r6r=r&r'r(r-r-4s:��N���"�,�"�(�"�(�	"�

�"r'r-c�\��eZdZ			ddddddd�																			d�fd�Z�xZS)�AsyncFileLockMetaFTN��blocking�is_singletonr rrc�n��|r|r
d}
t|
��t�|�	|||||||||	��	}td|�S)Nz:run_in_executor is not supported when thread_local is True)	�	lock_file�timeout�mode�thread_localrErFr rrr>)�
ValueError�super�__call__r
)
�clsrHrIrJrKrErFr rr�msg�instance�	__class__s
            �r(rNzAsyncFileLockMeta.__call__GsX����O�N�C��S�/�!��7�#����%��%��+��$�

���'��2�2r'����i�F)rH�str | os.PathLike[str]rI�floatrJ�intrKrrErrFrr rrrrrr?r>)r!r"r#rN�
__classcell__)rRs@r(rCrCFs������"�3��"�15� $�,0�3�)�3��3��	3�
�3��3��3�/�3��3�*�3�
�3�3r'rCc��eZdZdZ			ddddddd�																			dd�Zedd��Zedd��Zejdd	��Zedd
��Z			ddd�							dd�Z
ddd
�Zdd�Zdd�Z
dd�Z								d d�Zd!d�Zy)"r>z'Base class for asynchronous file locks.FTNrDc��||_||_tj|�||||||	d�}
|rtnt
di|
��|_y)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 blocking: whether the lock should be blocking or not
        :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.
        :param loop: The event loop to use. If not specified, the running event loop will be used.
        :param run_in_executor: If this is set to ``True`` then the lock will be acquired in an executor.
        :param executor: The executor to use. If not specified, the default executor will be used.

        )rHrIrJrEr rrNr&)�_is_thread_local�
_is_singleton�os�fspathr*r�_context)r2rHrIrJrKrErFr rr�kwargss           r(r3zBaseAsyncFileLock.__init__hs[��@!-���)���
���9�-��� ��.� �"
��0u�l�/J�`t�/
��/
��
r'c�.�|jjS)z"::return: whether run in executor.)r_rr5s r(rz!BaseAsyncFileLock.run_in_executor�s���}�}�,�,�,r'c�.�|jjS)z::return: the executor.�r_rr5s r(rzBaseAsyncFileLock.executor�s���}�}�%�%�%r'c�&�||j_y)z�
        Change the executor.

        :param value: the new executor or ``None``
        :type value: futures.Executor | None

        Nrc)r2�values  r(rzBaseAsyncFileLock.executor�s��"'��
�
�r'c�.�|jjS)z::return: the event loop.)r_r r5s r(r zBaseAsyncFileLock.loop�s���}�}�!�!�!r')rEc��K�|�|jj}|�|jj}|jxjdz
c_t	|�}|j
}t
j�}		|js:tjd||�|j|j��d{���|jrtjd||�n�|dur"tjd||�t|��d|cxkrt
j�|z
kr%nn"tjd||�t|��d	}tj||||�tj|��d{�����	t%|�
�S7��7�#t $r4t#d|jjdz
�|j_�wxYw�w)aW
        Try to acquire the file lock.

        :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default
            :attr:`~BaseFileLock.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 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()

        Nrz#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 ...r0)r_rIrE�lock_counter�idrH�time�perf_counter�	is_locked�_LOGGER�debug�_run_internal_method�_acquirer�asyncio�sleep�
BaseException�maxr-)r2rI�
poll_intervalrE�lock_id�
lock_filename�
start_timerPs        r(�acquirezBaseAsyncFileLock.acquire�s�����D�?��m�m�+�+�G����}�}�-�-�H�	
�
�
�"�"�a�'�"��T�(�����
��&�&�(�
�	���~�~��M�M�"G��R_�`��3�3�D�M�M�B�B�B��>�>��M�M�":�G�]�S���u�$��M�M�"O�QX�Zg�h�!�-�0�0���B�$�"3�"3�"5�
�"B�B��M�M�"F��Q^�_�!�-�0�0�J���
�
�c�7�M�=�I��m�m�M�2�2�2���'�D�1�1�!C��3���	�),�Q��
�
�0J�0J�Q�0N�)O�D�M�M�&��	�sD�A;G�>AF�F�CF�F�F�

G�F�F�=G�Gc��K�|jr�|jxjdzc_|jjdk(s|rzt|�|j}}t
j
d||�|j|j��d{���d|j_t
j
d||�yyy7�/�w)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/

        rrz#Attempting to release lock %s on %sNzLock %s released on %s)	rlr_rhrirHrmrnro�_release)r2�forcervrws    r(r8zBaseAsyncFileLock.release�s������>�>��M�M�&�&�!�+�&��}�}�)�)�Q�.�%�)+�D��4�>�>����
�
�C�W�m�\��/�/��
�
�>�>�>�-.��
�
�*��
�
�6���O�
38��?�s�BC�C�0Cc��K�tj|�r|��d{���y|jrG|jxstj�}|j|j
|��d{���y|�y7�`7��wr/)rq�iscoroutinefunctionrr �get_running_loopr)r2�methodr s   r(roz&BaseAsyncFileLock._run_internal_methodsg�����&�&�v�.��(�N�N�
�
!�
!��9�9�:�� 8� 8� :�D��&�&�t�}�}�f�=�=�=��H�
��
>�s"� B�B�AB�5B�6B�Bc��d}t|��)z�
        Replace old __enter__ method to avoid using it.

        NOTE: DO NOT USE `with` FOR ASYNCIO LOCKS, USE `async with` INSTEAD.

        :return: none
        :rtype: NoReturn
        z>Do not use `with` for asyncio locks, use `async with` instead.)�NotImplementedError)r2rPs  r(�	__enter__zBaseAsyncFileLock.__enter__s��O��!�#�&�&r'c��BK�|j��d{���|S7��w)zF
        Acquire the lock.

        :return: the lock object

        N)ryr5s r(r6zBaseAsyncFileLock.__aenter__ s!�����l�l�n�����	�s���c��@K�|j��d{���y7��w)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)r8r9s    r(r=zBaseAsyncFileLock.__aexit__*s�����l�l�n���s���c�J�tjt�5|jxst	j
�}|j
�s"|j|jd���n!|j|jd���ddd�y#1swYyxYw)z'Called when the lock object is deleted.T)r|N)
�
contextlib�suppress�RuntimeErrorr rqr�
is_running�run_until_completer8�create_task)r2r s  r(�__del__zBaseAsyncFileLock.__del__:so��
�
 �
 ��
.��9�9�:�� 8� 8� :�D��?�?�$��'�'����4��(@�A�� � ����D��!9�:�/�
.�
.�s�A6B�B"rS)rHrUrIrVrJrWrKrrErrFrr rrrrrr?r@)r?r)r?r)rerr?r@)r?r)Ng�������?)rIzfloat | NonerurVrEzbool | Noner?r-)F)r|rr?r@)r�zCallable[[], Any]r?r@)r?r	)r?rrA)r?r@)r!r"r#r$r3�propertyrr�setterr ryr8ror�r6r=r�r&r'r(r>r>esk��1�
��"�0
��"�15� $�,0�0
�)�0
��0
��	0
�
�0
��0
��0
�/�0
��0
�*�0
�
�0
�d�-��-��&��&��_�_�'��'��"��"�!%�#�B2�
!%�B2��B2��B2�
�B2�
!�
B2�HP�&�
'���,��(��(�	�

�� ;r'r>)�	metaclassc��eZdZdZy)�AsyncSoftFileLockz.Simply watches the existence of the lock file.Nr+r&r'r(r�r�Ds��8r'r�c��eZdZdZy)�AsyncUnixFileLockzHUses the :func:`fcntl.flock` to hard lock the lock file on unix systems.Nr+r&r'r(r�r�Hs��Rr'r�c��eZdZdZy)�AsyncWindowsFileLockzNUses the :func:`msvcrt.locking` to hard lock the lock file on windows systems.Nr+r&r'r(r�r�Ls��Xr'r�)r-r�r�r�r>)1r$�
__future__rrqr��loggingr]rj�dataclassesr�	threadingr�typingrrrr	r
�_apirr
r�_errorr�_softr�_unixr�_windowsr�sys�
concurrentr�typesr�version_infor�typing_extensions�	getLoggerrmrr*r-rCr>r�r�r��__all__r&r'r(�<module>r�s���7�"����	��!��?�?�=�=����%���"�#�
���7�"��*��'�
�
�J�
'���
2�?�
2��
2�C�"6��C�"�"�$3��3�>\;��0A�\;�~9��&7�9�S��&7�S�Y�?�,=�Y��r'

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic