← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/filelock/__pycache__/asyncio.cpython-312.pyc

253 lines

�

c�bj'��� �UdZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZdd	lmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$dd
l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1dd
l2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9er8ddl:Z:ddl;m<Z<m=Z=m>Z>m?Z?ddl@mAZAddlBmCZCe:j�dk\rddlmEZEnddlFmEZEej�d�ZHdeId<dZJdeId<dZKdeId<dZLdeId<gZMd eId!<ed"d#�$�ZNGd%�d&e�ZOGd'�d#eeO�(�ZPe	Gd)�d*e��ZQGd+�d,eQe
�ZRGd-�d.�ZSGd/�d0e3eP�ZTGd1�d2e5eP�ZUGd3�d4e1eP�ZVGd5�d6e7eP�ZWGd7�d8e9eP�ZXgd9�ZYy):z1An asyncio-based implementation of the file lock.�)�annotationsN)�	dataclass)�iscoroutinefunction)�local)�
TYPE_CHECKING�Final�NoReturn�TypeVar�cast�)�_UNSET_FILE_MODE�BaseFileLock�CloseErrorPolicy�ContextErrorPolicy�FileLockContext�FileLockMeta�_append_exception_context�
_canonical�_ExtraValue�_fork_transition�_grouped_errors�_raise_body_and_release�_raise_chained_errors�_raise_cleanup_errors�_raise_grouped_errors�_register_fork_object)�_AsyncTransitionGate� _AsyncTransitionUnavailableError�_BackendOutcome�_capture_awaitable�
_capture_call�
_drain_future�_future_result�_wait_until_done)�Timeout)�
SoftFileLease)�SoftFileLock)�StrictSoftFileLock)�UnixFileLock)�WindowsFileLock)�	Awaitable�Callable�	Coroutine�Hashable)�futures)�
TracebackType)��)�Self�filelockzFinal[logging.Logger]�_LOGGERz9lock release cancellation and backend release both failedz
Final[str]�"_ASYNC_RELEASE_CANCELLATION_ERRORSz>context body, release cancellation, and backend release failed�_ASYNC_CONTEXT_RELEASE_ERRORS�$_filelock_async_release_cancellation�'_ASYNC_RELEASE_CANCELLATION_MARKER_ATTRzFinal[list[None]]�"_ASYNC_RELEASE_CANCELLATION_MARKER�_AT�BaseAsyncFileLock)�boundc���eZdZdedfddddddddddddd�																																					d
�fd	�Z�xZS)�AsyncFileLockMeta�����FT皙�����?N�chain�default��blocking�is_singleton�
poll_interval�lifetime�context_error_policy�close_error_policy�fallback_to_soft�preserve_lock_file�on_acquired�loop�run_in_executor�executorc���|r|r
d}t|��t�|�di|�id|�d|�d|�d|�d|�d|�d|�d	|�d
|	�d|
�d|�d
|�d|
�d|�d|�d|���S)Nz:run_in_executor is not supported when thread_local is True�	lock_file�timeout�mode�thread_localrErFrGrHrIrJrKrLrMrNrOrP�)�
ValueError�super�__call__)�clsrRrSrTrUrErFrGrHrIrJrKrLrMrNrOrP�kwargs�msg�	__class__s                   ��g/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/filelock/asyncio.pyrYzAsyncFileLockMeta.__call__Hs����*�O�N�C��S�/�!��w��
��
��
��
��	
�
&�
��

�&�
�(�
��
�"6�
� 2�
�.�
� 2�
�$�
��
� ,�!
�"�#
�	
�)&rZz	type[_AT]rR�str | os.PathLike[str]rS�floatrT�intrU�boolrErcrFrcrGrarH�float | NonerIrrJrrKrcrLrcrM�Callable[[int], None] | NonerN� asyncio.AbstractEventLoop | NonerOrcrP�futures.Executor | Noner[r�returnr;)�__name__�
__module__�__qualname__r
rY�
__classcell__)r]s@r^r?r?Gs�����$�"�*
��"�#�!%�3:�/8�!%�#(�48�15� $�,0�%*
�
�*
�)�*
��*
��	*
�
�*
��*
��*
��*
��*
�1�*
�-�*
��*
�!�*
�2�*
� /�!*
�"�#*
�$*�%*
�&�'*
�(

�)*
�*
r_r?c�Z�eZdZUdZdZded<dZded<ed.d��Zd	e	d
fdd
dd
dddd
d
d
dd
d�																																	d/d�Z
ed0d��Zed1d��Z
e
jd2d��Z
ed3d��Z		d4d
d
d�									d5d�Z												d6d�Z												d7d�Zd8d�Zd9d�Zd:d�Z	d;									d<d�Zd=d>d�Zd>d�Zd8d �Z				d?d!�Zd@d"�Zd8d#�ZdAd$�ZdBd%�Zd8d&�Zd8d'�Z dCd(�Z!								dDd)�Z"dEd*�Z#								dDd+�Z$				dFd,�Z%d8d-�Z&y
)Gr<zP
    Base class for asynchronous file locks.

    .. versionadded:: 3.15.0

    z'BaseAsyncFileLock instance in this task�str�_deadlock_holder_desc�rb�(_constructor_lifetime_warning_stacklevelc�*�tj�S�N)�asyncio�current_taskrVr_r^�_deadlock_scopez!BaseAsyncFileLock._deadlock_scope�s���#�#�%�%r_r@FTrANrBrCrDc�6�tj�|_||_||_|	|_|
|_||_||_|
|_	t�|_|rtnttj|�||||||||��	|_t!|�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. When not specified, the OS controls permissions via umask and
            default ACLs, preserving POSIX default ACL inheritance in shared directories.
        :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. When ``True`` (the default), **all fields of the
            lock's internal context are per-thread**, including the configuration values ``poll_interval``, ``timeout``,
            ``blocking``, ``mode``, and ``lifetime``. Setting one of these properties from one thread does not change
            the value seen by another thread; threads that did not perform the write continue to see the value supplied
            at construction time. If you need configuration values to be visible across threads, construct the lock
            with ``thread_local=False``.
        :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 poll_interval: default interval for polling the lock file, in seconds. It will be used as fallback value
            in the acquire method, if no poll_interval value (``None``) is given.
        :param lifetime: for :class:`AsyncSoftFileLock`, the age in seconds after which a waiting process may delete
            the marker, even while its holder remains alive. This legacy expiry mode does not provide strict mutual
            exclusion. ``None`` (the default) disables age-based expiry. Native OS locks (:class:`AsyncFileLock`)
            cannot be revoked by file age and ignore a non-``None`` ``lifetime`` with a warning.
        :param context_error_policy: how a context manager reconciles a failure in its body with a failure while
            releasing on exit. ``"chain"`` (the default) keeps Python's behavior: the release error propagates with the
            body error in its ``__context__``. ``"group"`` raises a :class:`BaseExceptionGroup` holding the body error
            first and the release error second, so neither hides the other.
        :param close_error_policy: for native locks (:class:`AsyncFileLock`), what to do with an ``os.close`` failure
            after the OS unlock has already committed. ``"default"`` keeps each platform's historical behavior,
            ``"raise"`` always propagates the ``OSError``, and ``"suppress"`` always ignores it.
        :param fallback_to_soft: for :class:`AsyncFileLock`, whether to fall back to soft existence locking when
            ``flock`` returns ``ENOSYS``. ``True`` (default) keeps the fallback; ``False`` propagates the error.
        :param preserve_lock_file: for native locks (:class:`AsyncFileLock`), whether filelock promises not to unlink
            the lock pathname on release. ``False`` (default) keeps each backend's cleanup; ``True`` keeps a stable file
            identity (Windows skips its unlink, Unix refuses the ``ENOSYS`` soft fallback). :class:`AsyncSoftFileLock`
            rejects ``True``.
        :param on_acquired: for native locks (:class:`AsyncFileLock`), a callable invoked with the borrowed lock
            descriptor once per physical acquisition, after the lock is held but before
            :meth:`~BaseAsyncFileLock.acquire` returns. With ``run_in_executor=True`` (the default) it runs in the
            backend executor. It must not close or unlock the descriptor; a raise rolls the acquisition back.
            :class:`AsyncSoftFileLock` rejects it.
        :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.

        )	rRrSrTrErGrHrNrOrPN)�os�getpid�_creator_pid�_is_thread_local�
_is_singleton�_context_error_policy�_close_error_policy�_fallback_to_soft�_preserve_lock_file�_on_acquiredr�_transition_gate�AsyncThreadLocalFileContext�AsyncFileLockContext�fspath�_contextr)�selfrRrSrTrUrErFrGrHrIrJrKrLrMrNrOrPs                 r^�__init__zBaseAsyncFileLock.__init__�s���J�I�I�K��� ,���)���%9��"�#5�� �!1���#5�� �'���=Q�=S���/t�l�/J�`t��i�i�	�*����'���+��
/
��
�	�d�#r_c�.�|jjS)zWhether run in executor.)r�rO�r�s r^rOz!BaseAsyncFileLock.run_in_executor�s���}�}�,�,�,r_c�.�|jjS)z
The executor.�r�rPr�s r^rPzBaseAsyncFileLock.executor�s���}�}�%�%�%r_c�&�||j_y)zs
        Change the executor.

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

        Nr�)r��values  r^rPzBaseAsyncFileLock.executor�s��"'��
�
�r_c�.�|jjS)zThe event loop.)r�rNr�s r^rNzBaseAsyncFileLock.loop�s���}�}�!�!�!r_)rE�cancel_checkc��jK�|j�|�|jj}|�|jj}|�|jj}tj�}	|j|||||���d{���S7�#t$rt|j�d�wxYw�w)a�
        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, ``None`` means use the default
            :attr:`~BaseFileLock.poll_interval`
        :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.
        :param cancel_check: a callable returning ``True`` when the acquisition should be canceled. Checked on each poll
            iteration. When triggered, raises :class:`~Timeout` just like an expired timeout.

        :returns: a context object that will unlock the file when the context is exited

        :raises Timeout: if fails to acquire lock within the timeout period

        .. 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()

        N�rEr�rSrG�
start_time)�_raise_if_inheritedr�rSrErG�time�perf_counter�_acquire_with_admissionrr%rR)r�rSrGrEr�r�s      r^�acquirezBaseAsyncFileLock.acquire�s�����N	
� � �"��?��m�m�+�+�G����}�}�-�-�H�� � �M�M�7�7�M��&�&�(�
�		4��5�5�!�)��+�%�6���
���0�	4��$�.�.�)�t�3�	4�s0�A-B3�0B�	B�
B�
B3�B� B0�0B3c��~K�|jj|||dkrdn||z|��4�d{���t|j�}|jxj
dz
c_|j
|||��||j_	|j|||||���d{���	d|j_|j|�t|��cddd��d{���S7��7�F#t$r|j|��wxYw#d|j_wxYw7�>#1�d{���7swYyxYw�w)Nr)rEr��deadlinerGr)rSrEr���lock)
r��hold_for_acquirerrRr��lock_counter�_raise_if_would_deadlock�
claim_root�_async_poll_until_acquired�
BaseException�_reconcile_failed_acquire�_commit_acquire�AsyncAcquireReturnProxy)r�rEr�rSrGr��	canonicals       r^r�z)BaseAsyncFileLock._acquire_with_admission:s5�����(�(�9�9��%�$�q�[�T�j�7�.B�'�	:�
�
�#�4�>�>�2�I��M�M�&�&�!�+�&��)�)�)�W�x�)�X�'0�D�M�M�$�
0��5�5�%�!-�#�"/�)�6����,0��
�
�(�� � ��+�*��5�3
�
�
����!�
��.�.�y�9��
��,0��
�
�(��/
��
�
�
�s{�.D=�C-�D=�AD(�C1�(C/�)C1�.-D(�D=�'D&�(D=�/C1�1D
�
D�D#�#D(�&D=�(D:�.D1�/D:�6D=c��K�t|�}|j}	|j�|jsO|j	�t
j
d||�|j��d{���|j�|jrt
j
d||�y|j||||��rt|��t
j
d|||�tj|��d{�����7��7��w)Nz#Attempting to acquire lock %s on %szLock %s acquired on %s)rEr�rSr�z2Lock %s not acquired on %s, waiting %s seconds ...)�idrRr��	is_locked�_try_break_expired_lockr5�debug�_run_acquire_attempt�_check_give_upr%rt�sleep)r�rEr�rSrGr��lock_id�
lock_filenames        r^r�z,BaseAsyncFileLock._async_poll_until_acquired^s������T�(�����
���$�$�&��>�>��,�,�.��
�
�C�W�m�\��/�/�1�1�1��(�(�*��~�~��
�
�6���O���"�"�!�)��%�	#���m�,�,��M�M�N�PW�Yf�hu�v��-�-�
�.�.�.�%�
2��
/�s%�A/D�1D�2BD�:D�;D�Dc���K�|jt|j�r|jn|j�}	t|��d{���	t|�y7�#tj$r�}d}	t|��d{���7n#t$r}|}Yd}~nd}~wwxYwd}|jr<	t|j���d{���7n#t$r}|}Yd}~nd}~wwxYw|�)|�|jd|||�|jd||�|�|jd||��d}~wwxYw#tj$r$}|j|��d{���7Yd}~yd}~wwxYw�w)NzClock acquisition cancellation, backend attempt, and rollback failedz=lock acquisition cancellation and backend attempt both failedz6lock acquisition cancellation and rollback both failed)�_start_internal_methodr�_acquire�!_acquire_with_fork_tracking_async�_acquire_with_fork_trackingr$rt�CancelledErrorr"r�r��_start_tracked_release�_raise_cancelled_errorsr#�#_rollback_backend_cancelled_acquire)r��acquire_future�cancellation�
acquire_error�error�rollback_errors      r^r�z&BaseAsyncFileLock._run_acquire_attempt}sp�����4�4�"�4�=�=�1�
�2�2��1�1�
��
	�"�>�2�2�2�>	J��>�*�A
3���%�%�	�26�M�
&�#�N�3�3�3�� �
&� %�
��
&��48�N��~�~�+�'��(C�(C�(E�F�F�F��$�+�%*�N��+���(�!�-��0�0�]�$�%�&�	��,�,�S�Ua�cp���)��,�,�L�l�\j��
��;	��@�%�%�	J��:�:�=�I�I�I��	J�s��=E2�A"�A �A"�D8�E2� A"�"D5�5D0�8B
�B	�B
�D0�
	B"�B�D0�B"�"D0�4C�C�C�D0�	C,� C'�"D0�'C,�,AD0�0D5�5E2�8E/�E*�E"� E*�%E2�*E/�/E2c���K�|jr$	t|j���d{���|�|�7�#t$r}|j	||�Yd}~|�d}~wwxYw�wrs)r�r"r�r��_raise_acquire_rollback_errors�r�r�r�s   r^r�z5BaseAsyncFileLock._rollback_backend_cancelled_acquire�sg�����>�>�
S�#�D�$?�$?�$A�B�B�B���m��C�� �
S��3�3�M�>�R�R����
S�s7�
A �7�5�7�A �7�	A�A�A �A�A c�T�|jdk(r
td||�t||�y)N�groupz1lock acquisition backend and rollback both failed)r}rrr�s   r^r�z0BaseAsyncFileLock._raise_acquire_rollback_errors�s)���%�%��0�!�"U�Wd�ft�u��m�^�<r_c��|jdk(r8|tk(rttfnd}|�t	||||��t	|||||��|j
x}�%||ur!|j
x}�t
||�||_||_t||�y)Nr�)�marker)r}r6r9r:r�__context__rr)r��messager��first_error�second_errorr��context�cancellation_contexts        r^r�z)BaseAsyncFileLock._raise_cancelled_errors�s����%�%��0��@�@�9�:\�]��
�
�#�%�g�|�[�QW�X�!�'�<��l�[a�b�"�.�.�.�G�;��|�@[�(4�(@�(@�@�$�M�)�'�3G�H�'.�L�$�".����k�<�8r_c��8K�|jtj�k7s|jsy|jj�4�d{���|j
|���d{���ddd��d{���y7�/7�7�	#1�d{���7swYyxYw�w)a1
        Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file
        itself may be deleted automatically, the behavior is platform-specific.

        :param force: If true, the lock counter is ignored and the lock is released in every case.

        N��force)rzrxryr�r��hold�_release_serialized)r�r�s  r^�releasezBaseAsyncFileLock.release�sp��������	�	��+�4�>�>���(�(�-�-�/�/��*�*��*�7�7�7�0�/�/��7��0��/�/�/�sZ�A
B�A?�B�B�)B�*B�.B�9B�:B�B�B�B�B�B�Bc���K�|jsy|s9|jjdkDr |jxjdzc_yt|�|j}}t
j
d||�|j�}	t|��d{���	t#|�|j!�t
j
d||�y7�8#tj$ri}	t|��d{���7n=#t$r1}|j�|jt||�Yd}~nd}~wwxYw|j!��d}~wwxYw#t$r|j��wxYw�w)Nrz#Attempting to release lock %s on %szLock %s released on %s)r�r�r�r�rRr5r�r�r$rtr�r"r��_commit_release_if_releasedr�r6�_commit_releaser#)r�r�r�r��release_futurer��
release_errors       r^r�z%BaseAsyncFileLock._release_serialized�s?�����~�~������3�3�a�7��M�M�&�&�!�+�&��!#�D��4�>�>����
�
�;�W�m�T��4�4�6��		�"�>�2�2�2�	��>�*�	
�����
�
�.���G�
3���%�%�	�
n�#�N�3�3�3�� �
n��0�0�2��,�,�-O�Q]�_l�m�m��
n��
� � �"���	���	��,�,�.��	�s~�BE0�
C�C�C�E�)(E0�C�E�'C<�5C8�6C<�;E
�<	D6�'D1�,E
�1D6�6E
�
E�E0�E-�-E0c�>�|js|j�yyrs)r�r�r�s r^r�z-BaseAsyncFileLock._commit_release_if_released�s���~�~�� � �"�r_c	�d�t|�r-tjtt	d|����Stj
�}t	d|�}|jr!|j
|jt|�S|j�}|jt|��|S)Nz)Callable[[], Coroutine[None, None, None]]zCallable[[], None])rrt�create_taskr r�get_running_looprOrPr!�
create_future�
set_result)r��methodrN�sync_method�futures     r^r�z(BaseAsyncFileLock._start_internal_method�s����v�&��&�&�'9�:s�$�?j�lr�:s�:u�'v�w�w��'�'�)���/��8������'�'��
�
�}�k�R�R�8<�8J�8J�8L�����-��4�5��
r_c��|jt|j�r|j�S|j�Srs)r�r�_release�!_release_with_fork_tracking_async�_release_with_fork_trackingr�s r^r�z(BaseAsyncFileLock._start_tracked_releasesA���*�*�"�4�=�=�1�
�2�2�
�	
��1�1�
�	
r_c��K�t|�5	td|j���d{���	|j�	ddd�|jr|j��d{���yy7�D#t$r }|j	|��d{���7�d}~wwxYw#t$r }|j
|��d{���7�d}~wwxYw#1swY��xYw7�l�w�NzCallable[[], Awaitable[None]])	rrr�r��_rollback_failed_acquire_async�_register_context_descriptor�#_rollback_failed_registration_asyncr��_invoke_on_acquired_async)r��acquisition_error�registration_errors   r^r�z3BaseAsyncFileLock._acquire_with_fork_tracking_asyncs�����
�d�
#�
�J�d�:�D�M�M�J�L�L�L�
��1�1�3�$��>�>��0�0�2�2�2��M�� �
��9�9�:K�L�L�L���
��
!�
��>�>�?Q�R�R�R���
��$�
#��
3�s��C�C
�A5�A3�A5�B!�'C�,C�-C�3A5�5	B�>B�B�B�B�C
�!	C
�*C�>C�?C�C
�
C
�
C�Cc��K�|jsyd}d}	|j�	t	|j���d{���|�td|||�yy#t$r6}|}	|j�n#t$r}|}Yd}~nd}~wwxYwYd}~�nd}~wwxYw7�X#t$r/}|�|�|j
||�td||||�Yd}~��d}~wwxYw�w)Nzlock acquisition cleanup failed)r�r�r��'_register_unverified_context_descriptorr"r�r�r)r�r�r��tracking_errorr�r�s      r^r�z0BaseAsyncFileLock._rollback_failed_acquire_asyncs������~�~��37��/3��	'��-�-�/�	��� ;� ;� =�>�>�>��)�!�1�3D�FX�Zh�
�*��'�	'�!&��
'��<�<�>�� �
'�!&���
'���	'��
?���		�!�)�n�.D��3�3�4E�~�V�!�1�!�"���
�
��		�s��C�A�B�B�B�C�	B�"B�%A6�5B�6	B�?B�B�B�B�C�B�C�B�	C�&%C�C�C�Cc��K�d}	|j�	t|j���d{���|�t	d||�yy#t$r}|}Yd}~�Cd}~wwxYw7�-#t$r}t	d|||�Yd}~�Gd}~wwxYw�w)Nz&descriptor registration cleanup failed)r�r�r"r�r)r�r�r�r�r�s     r^r�z5BaseAsyncFileLock._rollback_failed_registration_async=s�����/3��	#��8�8�:�	��� ;� ;� =�>�>�>�
�%�!�"J�L^�`n�o�&���	#�"�N��	#��
?���	�!�8�:L�n�^l�
�
��	�s`�B�A	�A#�A!�A#�B�		A�A�B�A�B�!A#�#	B�,A?�:B�?B�Bc��K�|j�|jjdk7ry	|jtd|jj��y#t
$re}|j}	t|j���d{���7||_�#t
$r}t||�Yd}~||_�d}~wwxYwd}~wwxYw�w)Nrrb)
r�r�r�r�lock_file_fdr�r�r"r�r)r��callback_error�callback_contextr�s    r^r�z+BaseAsyncFileLock._invoke_on_acquired_asyncMs��������$��
�
�(B�(B�a�(G��		����d�5�$�-�-�*D�*D�E�F���	�-�9�9��
G�#�D�$?�$?�$A�B�B�B�*:�N�&���!�
G�'��
�F�F�)9�N�&���
G��		�s^�'C�/A�C�	C�#C�0B�B�
B�C�	C�#B;�/C�;C�C�C�Cc���K�t|�5	td|j���d{���|j�	ddd�y7�#|j�wxYw#1swYyxYw�wr�)rrr��_unregister_released_descriptorr�s r^r�z3BaseAsyncFileLock._release_with_fork_tracking_async[sZ����
�d�
#�
7�J�d�:�D�M�M�J�L�L�L��4�4�6�	$�
#�L���4�4�6��	$�
#�sB�A0�A$�A�A
�A�A$�	A0�
A�A!�!A$�$A-�)A0c��d}t|��)zTSync context manager entry is not supported because lock acquisition is a coroutine.�aUse `async with`: acquire/release are coroutines and cannot be awaited in a sync context manager.��NotImplementedError)r�r\s  r^�	__enter__zBaseAsyncFileLock.__enter__bs��q��!�#�&�&r_c��d}t|��)zOSync context manager exit is not supported because lock release is a coroutine.r�r�)r��exc_type�	exc_value�	tracebackr\s     r^�__exit__zBaseAsyncFileLock.__exit__gs��r��!�#�&�&r_c��BK�|j��d{���|S7��w)zG
        Acquire the lock.

        :returns: the lock object

        N)r�r�s r^�
__aenter__zBaseAsyncFileLock.__aenter__qs!�����l�l�n�����	�s���c��BK�|j|��d{���y7��w)a%
        Release the lock, reconciling a release failure with any body failure per :attr:`context_error_policy`.

        :param exc_type: the exception type if raised
        :param exc_value: the exception value if raised
        :param traceback: the exception traceback if raised

        N)�_release_in_context�r�r�r�r�s    r^�	__aexit__zBaseAsyncFileLock.__aexit__{s�����&�&�y�1�1�1�s���c��pK�	|j��d{���y7�#t$r�}|��|jdk(r
t||��t	|t
ttf�x}	�8| r4dk(r/\xtjd�x�\}}tt|||�nt||�Yd}~yd}~wwxYw�w)NrB�rV)
r�r�r}rrr6r9r:rtr�rr7r)r��
body_errorr��errorsr��
backend_errors      r^rz%BaseAsyncFileLock._release_in_context�s�����	?��,�,�.� � ���	?��!���)�)�W�4�)�-��D��)�!�6�<�>`�a����
�
��R�R�B�'�0�0�2�R�-�.K�Z�Ye�gt�u�S�#�J�
�>�>��#	?�s7�B6����B6��	B3�BB.�)B6�.B3�3B6c�j�t|�jd�tj�k7ryt	j
t�5	tj�}|�
	ddd�y|j�s"|j|jd���n!|j!|jd���ddd�y#t$rU|jjr:|jjj�s|jjnd}Y��wxYw#1swYyxYw)zORelease on deletion; safe to call during GC even when no event loop is running.rzNTr�)�vars�getrxry�
contextlib�suppress�	Exceptionrtr��RuntimeErrorr�rN�	is_closed�
is_running�run_until_completer�r�)r�rNs  r^�__del__zBaseAsyncFileLock.__del__�s�����:�>�>�.�)�R�Y�Y�[�8��
�
 �
 ��
+�
q��/�/�1���|��
,�
+��?�?�$��'�'����4��(@�A�� � ����D��!9�:�,�
+�� �
q�-1�]�]�-?�-?��
�
�HZ�HZ�Hd�Hd�Hf�t�}�}�)�)�lp��
q��,�
+�s8�
D)�C� D)�,AD)�AD&�#D)�%D&�&D)�)D2)rhzHashable | None)"rRr`rSrarTrbrUrcrErcrFrcrGrarHrdrIrrJrrKrcrLrcrMrerNrfrOrcrPrgrh�None)rhrc)rhrg)r�rgrhr)rhrf)NN)
rSrdrGrdrEzbool | Noner��Callable[[], bool] | Nonerhr�)rErcr�rrSrarGrar�rarhr�)rErcr�rrSrarGrar�rarhr)rhr)r��asyncio.CancelledErrorrhr	)r�r�r�r�rhr	rs)
r�rnr�rr�r�r��BaseException | Nonerhr	)F)r�rcrhr)r�z>Callable[[], None] | Callable[[], Coroutine[None, None, None]]rh�%asyncio.Future[_BackendOutcome[None]])rhr)r�r�rhr)r�r�rhr)rhr	�r�ztype[BaseException] | Noner�rr�zTracebackType | Nonerhr)rhr3)rrrhr)'rirjrk�__doc__ro�__annotations__rq�staticmethodrvr
r��propertyrOrP�setterrNr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrVr_r^r<r<usT���"K��3�J�45�,�c�5��&��&��$�"�Z$��"�#�!%�3:�/8�!%�#(�48�15� $�,0�%Z$�)�Z$��Z$��	Z$�
�Z$��Z$��Z$��Z$��Z$�1�Z$�-�Z$��Z$�!�Z$�2�Z$� /�!Z$�"�#Z$�$*�%Z$�&
�'Z$�x�-��-��&��&��_�_�'��'��"��"�!%�&*�;4�
!%�26�
;4��;4�$�;4�
�;4�0�
;4�
!�;4�z"6��"6�0�	"6�
�"6��
"6��"6�
!�"6�H/��/�0�	/�
�/��
/��/�
�/�>)J�V�=�.2�9��9�-�9�#�	9�
+�9�
�
9�.8�H�8#��T��	.��
�
3��>p� �7�'�
'�,�'�(�'�(�	'�

�'��2�,�2�(�2�(�	2�

�2� ?�.�?�	
�?�2;r_)�	metaclassc�<�eZdZUdZdZded<dZded<dZded	<y)
r�zGA dataclass which holds the context for a ``BaseAsyncFileLock`` object.TrcrONrgrPrfrN)rirjrkrrOrrPrNrVr_r^r�r��s+��Q�!�O�T� �)-�H�%�,�.2�D�
*�1r_r�c��eZdZdZy)r�z8A thread local version of the ``FileLockContext`` class.N�rirjrkrrVr_r^r�r��s��Br_r�c�8�eZdZdZdd�Zdd�Z								dd�Zy)	r�zDA context-aware object that will release the lock file when exiting.c��||_yrsr�)r�r�s  r^r�z AsyncAcquireReturnProxy.__init__�s	����	r_c��"K�|jS�wrsr�r�s r^rz"AsyncAcquireReturnProxy.__aenter__�s�����y�y��s�
c��VK�|jj|��d{���y7��wrs)r�rrs    r^rz!AsyncAcquireReturnProxy.__aexit__�s �����i�i�+�+�I�6�6�6�s�)�'�)N)r�r<rhr)rhr<r)rirjrkrr�rrrVr_r^r�r��s:��N���7�,�7�(�7�(�	7�

�7r_r�c� �eZdZUdZdZded<y)�AsyncSoftFileLockz.Simply watches the existence of the lock file.)�AsyncStrictSoftFileLock�AsyncSoftFileLeaseztuple[str, str] | None�_lifetime_replacementsN)rirjrkrr-rrVr_r^r*r*�s��8�5f��2�fr_r*c��eZdZdZy)r+z?Run strict owner-claim locking without blocking the event loop.Nr$rVr_r^r+r+�s��Ir_r+c��eZdZdZy)r,z_Existence lock whose claim expires, so a peer may take it while the previous holder still runs.Nr$rVr_r^r,r,�s��ir_r,c��eZdZdZy)�AsyncUnixFileLockzHUses the :func:`fcntl.flock` to hard lock the lock file on unix systems.Nr$rVr_r^r1r1�s��Rr_r1c��eZdZdZy)�AsyncWindowsFileLockzNUses the :func:`msvcrt.locking` to hard lock the lock file on windows systems.Nr$rVr_r^r3r3�s��Xr_r3)r�r,r*r+r1r3r<)Zr�
__future__rrtr�loggingrxr��dataclassesr�inspectr�	threadingr�typingrrr	r
r�_apir
rrrrrrrrrrrrrrr�_asyncrrrr r!r"r#r$�_errorr%�_leaser&�_softr'�_strictr(�_unixr)�_windowsr*�sys�collections.abcr+r,r-r.�
concurrentr/�typesr0�version_infor3�typing_extensions�	getLoggerr5rr6r7r9r:r;r?r<r�r�r�r*r+r,r1r3�__all__rVr_r^�<module>rJs���7�"����	��!�'��@�@������$	�	�	��!��'��%���H�H�"�#�
���7�"��*�"3��!2�!2�:�!>��	�>�1l�"�J�l�,l��z�l�6\�'��\�8:�"�$5�:�
�e�.�/��+
��+
�\};��0A�};�@�
2�?�
2��
2�C�"6��C�7�7�$g��&7�g�J�0�2C�J�j��(9�j�S��&7�S�Y�?�,=�Y��r_