← back to Atmos Game

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

472 lines

�

c�bjWA���UddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
ddlmZmZddlmZddlmZddlmZmZddlmZmZmZmZdd	lmZmZmZm Z m!Z!m"Z"m#Z#dd
l$m%Z%m&Z&ddl'm(Z(m)Z)dd
l*m+Z+dZ,de-d<dZ.de-d<edZ/e0ddh�Z1de-d<edZ2e0hd��Z3de-d<erfddlm4Z4ddl5m6Z6ddlm7Z7ddl8m9Z9ddl:m;Z;Gd �d!e7�Z<Gd"�d#e7�Z=Gd$�d%e7�Z>Gd&�d'e7�Z?ej�d(k\rdd)lmAZAndd)lBmAZAej�d*�ZDd+e-d,<e#d-eEed.d��ZFd/e-d0<eFduZGd1e-d2<e"d3�ZHe"d4�ZIe"d5�ZJeKeLzeMzeNzdzeeLgdfzZOGd6�d7e!d8�9�ZPd�d:�ZQdd;�											d�d<�ZRd�d=�ZSd�d>�ZTd�d?�ZUd�d@�ZVd�dA�ZW								d�dB�ZXerGdC�dDe7�ZYd�d�dE�ZZd�dF�Z[d�dG�Z\								d�dH�Z]ej�dIk(rej�j�nej�j�ZbdJe-dK<d�dL�ZcGdM�dNe�Zded�ZedOe-dP<e"dQdR�S�ZfGdT�dUe�Zge%�ZhdVe-dW<d�dY�ZiedZ�[�Gd\�dX��Zjd�d]�Zkd�d^�Zld�d_�Zmd�d`�Zn								d�da�ZoGdb�dRej�eg�c�ZqGdd�de�ZreGdf�dg��ZsGdh�diese�ZtedZ�[�Gdj�dk��ZuGdl�dme�ZvGdn�do�Zwe&�Zxdpe-dq<e&�Zydre-ds<iZzdte-du<e�Z{dve-dw<e�Z|dve-dx<ew�Z}dye-dz<e0d{d|h�Z~de-d}<d�d~�Zed�d�d��Z�d�d��Z�d�d��Z�d�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�								d�d��Z�d�d��Z�						d�d��Z�e�gd��Z�y)��)�annotationsN)�ABCMeta�abstractmethod)�Callable�Hashable)�contextmanager)�	dataclass)�count�starmap)�	Condition�RLock�	get_ident�local)�
TYPE_CHECKING�Final�Literal�NoReturn�	TypedDict�TypeVar�cast)�WeakKeyDictionary�WeakValueDictionary�)�SoftFileLockLifetimeWarning�Timeout)�break_lock_file�����z
Final[int]�_UNSET_FILE_MODE��_MAX_BACKOFF_EXPONENT)�chain�groupr!r"zFinal[frozenset[str]]�_CONTEXT_ERROR_POLICIES)�default�raise�suppress>r%r$r&�_CLOSE_ERROR_POLICIES)�	Generator)�
TracebackType)�Protocol)�
ReadWriteLock)�SoftReadWriteLockc��eZdZdd�Zy)�_ForkResettablec��y�N���selfs �d/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/filelock/_api.py�_reset_after_fork_in_childz*_ForkResettable._reset_after_fork_in_child0s��c�N��return�None)�__name__�
__module__�__qualname__r5r1r6r4r.r./s��9r6r.c��eZdZdd�Zy)�_ForkDescriptorOwnerc��yr0r1r2s r4�_descriptors_for_forkz*_ForkDescriptorOwner._descriptors_for_fork3s��[^r6N�r8z.tuple[tuple[int, tuple[int, int] | None], ...])r:r;r<r@r1r6r4r>r>2s��^r6r>c��eZdZdd�Zy)�_ForkResettableClassc��yr0r1r2s r4�_reset_class_after_forkz,_ForkResettableClass._reset_class_after_fork8s��3r6Nr7)r:r;r<rEr1r6r4rCrC7s��6r6rCc�,�eZdZdddd�							dd�Zy)�_RegisterAtForkN��before�after_in_parent�after_in_childc��yr0r1)r3rIrJrKs    r4�__call__z_RegisterAtFork.__call__;s��r6)rI�Callable[[], None] | NonerJrNrKrNr8r9)r:r;r<rMr1r6r4rGrG:s:��15�9=�8<�	�.�	�7�		�
6�	��
	r6rG���)�Self�filelockzFinal[logging.Logger]�_LOGGERz_RegisterAtFork | None�register_at_forkzFinal[_RegisterAtFork | None]�_REGISTER_AT_FORKzFinal[bool]�_HAS_REGISTER_AT_FORK�_ExtraValue�_MarkerValue�_SubclassValuec��eZdZUdZded<ded<ded<ded<ded	<ded
<ded<d
ed<ded<ded<ded<ded<y)�LockOptionszhEvery option the metaclass forwards, so a subclass adding its own can still type what it passes through.�float�timeout�int�mode�bool�thread_local�blocking�is_singleton�
poll_interval�float | None�lifetime�ContextErrorPolicy�context_error_policy�CloseErrorPolicy�close_error_policy�fallback_to_soft�preserve_lock_file�Callable[[int], None] | None�on_acquiredN)r:r;r<�__doc__�__annotations__r1r6r4r\r\RsJ��r�
�N�

�I����N�������,�,�(�(�����-�-r6r\F)�totalc�D�tjdk\rtSddlm}|S)NrOr)�BaseExceptionGroup)�sys�version_infort�exceptiongroup)�	_Backports r4�_exception_group_clsrycs%�����7�"�!�!���r6)�markerc�x�||g|��}t|�t�||�}|�t||d|d�|d�)Nrr)�_detach_grouped_contextsry�setattr)�message�first_error�second_errorrz�additional_errors�errorsr"s       r4�_raise_grouped_errorsr�psP���<�
<�*;�
<�F��V�$�"� �"�7�F�3�E�
����v�a�y�&��)�,�
�T�r6c���t�}t|�}|r�|j�}t|�|vr� |j	t|��|j
x��,�|us t
|��st�fd�|D��rd|_n��|j��|j�|j|j�t|t��r%|jtd|�j�|r��yy)Nc3�B�K�|]}�|uxst|�����y�wr0)�_contains_exception)�.0�root�contexts  �r4�	<genexpr>z+_detach_grouped_contexts.<locals>.<genexpr>�s(�����\�U[�T�7�d�?�H�&9�$��&H�H�U[�s��_ExceptionGroupProtocol)�set�list�pop�id�add�__context__�_same_exception_tree�any�append�	__cause__�
isinstancery�extendr�
exceptions)r��seen�pending�errorr�s    @r4r|r|s�����U�D��6�l�G�
����
��
�e�9��������E����(�(�(�G�5��u��#�E�7�3��\�U[�\�\� $�E��
�
 ��N�N�7�#��?�?�&��N�N�5�?�?�+��e�1�3�4��N�N�4� 9�5�A�L�L�M�!r6c�R�||fg}t�}|�r|j�\}}||ur�t|�t|�fx}|vr�6|j|�t	|�t	|�us(t|t
��rt|t
��sytd|�}td|�}|j|jk7s+t|j�t|j�k7ry|jt|j|jd���|r��y)NFr�T)�strict)
r�r�r�r��typer�ryrr~�lenr�r��zip)	�first�secondr�r�rr��pair�first_group�second_groups	         r4r�r��s	���v���G�!$��D�
�$+�K�K�M�!��\��,�&����_�b��&6�7�7�D�D�@����������T�,�%7�7��k�+?�+A�B��l�,@�,B�C���4�k�B���5�|�D�����,�"6�"6�6�#�k�>T�>T�:U�Y\�]i�]t�]t�Yu�:u�����s�;�1�1�<�3J�3J�SW�X�Y�#�$r6c�z�|�t|t��syttd|�j�}t�}|ry|j
�}||uryt|�|vr�%|jt|��t|t��r%|jtd|�j�|r�yy)NFr�T)
r�ryr�rr�r�r�r�r�r�)r��targetr�r��childs     r4r�r��s���
�~�Z��/C�/E�F���4�1�5�9�D�D�E�G��U�D�
����
���F�?��
�e�9��������E����e�1�3�4��N�N�4� 9�5�A�L�L�M��r6c�B�t||�st||�ry|j�||_y|}t�}t|�|vrY|j	t|��|j
�|j
n|jx}�||_y|}t|�|vr�Xyyr0)�_exception_graph_containsr�r�r�r�r�)r�r��tailr��
next_errors     r4�_append_exception_contextr��s��� ���0�4M�g�W\�4]����� �#�����D��U�D�
�T�(�$�
�����D���,0�N�N�,F�$�.�.�D�L\�L\�\�J�e�&�D�����
�T�(�$�
r6c��|g}t�}|r�|j�}||uryt|�|vr�%|jt|��|j�|j|j�|j�|j|j�t|t��r%|jtd|�j�|r��y)NTr�F)r�r�r�r�r�r�r�r�ryr�rr��r�r�r�r��currents     r4r�r��s����g�G��U�D�
��+�+�-���f���
�g�;�$�������G������(��N�N�7�,�,�-����*��N�N�7�.�.�/��g�3�5�6��N�N�4� 9�7�C�N�N�O��r6c��t|t��sytd|�}|j|k(r!t	||dd�|dur|j
SdS)Nr�rr)r�ryrr~�getattrr�)r�r~rzr"s    r4�_grouped_errorsr��s\���e�1�3�4���*�E�2�E�$�}�}��7�G�E�6�RS�9�VZ�<[�_e�fg�_h�<h�5���r�nr�rr6c�0�eZdZedd��Zedd��Zy)r�c��yr0r1r2s r4r~z_ExceptionGroupProtocol.message�s��"%r6c��yr0r1r2s r4r�z"_ExceptionGroupProtocol.exceptions�s��;>r6N�r8�str)r8�tuple[BaseException, ...])r:r;r<�propertyr~r�r1r6r4r�r��s��	�%�
�%�	�>�
�>r6r�c�&�|�|j}	|�|jx}�||urt||�t||�|j}	|�#t$r	||_�wxYw#t$r'||_	|�#t$r||_||_�wxYwwxYwr0)r��
BaseException�_detach_exception_contextr�)rr��
first_context�second_contexts    r4�_raise_chained_errorsr��s�����#�/�/�
�	���'�2�2�2��?�N�Ze�De�!�.�+�>�!�+�~�>��+�+�M�	�����	�&3�K�#��	����"/���	�����	�'2�L�$�&3�K�#��	��	�s)�A�	A �A� B�1A3�3B�Bc���|g}t�}|r�|j�}t|�|vr� |jt|��|j|urd|_n'|j�|j|j�|j�|j|j�t|t��r%|jtd|�j�|r��yy)Nr�)r�r�r�r�r�r�r�r�ryr�rr�r�s     r4r�r�s����g�G��U�D�
��+�+�-��
�g�;�$�������G������&�(�"&�G��
�
 �
 �
,��N�N�7�.�.�/����(��N�N�7�,�,�-��g�3�5�6��N�N�4� 9�7�C�N�N�O�r6c��td||�y)Nz!lock body and release both failed�r�)�
body_error�
release_errors  r4�_raise_body_and_releaser�s��
�=�z�=�Yr6c�,�t||gd�|D����y)Nc3�&K�|]	}|��|���y�wr0r1)r�r�s  r4r�z(_raise_cleanup_errors.<locals>.<genexpr>.s����	A�^�E�u�/@�%�^�s��r�)r~�
primary_error�cleanup_errorss   r4�_raise_cleanup_errorsr�&s"��
����
B�^�	A�r6�win32zFinal[Callable[[str], str]]�_resolve_dirc���tjjtj|��\}}tjj	t|xstj�|�S)a�
    Return one stable key for *path*, collapsing equivalent spellings without following a final symlink.

    Relative, absolute, and ``./`` spellings of one lock file must map to a single singleton instance, deadlock-registry
    entry, and removal key. Resolving the whole path with ``realpath`` would follow a final symlink and alias a lock
    target the backend deliberately rejects, so the registry identity would differ from the backend's. Resolving only
    the parent directory and re-appending the literal final component collapses the equivalent spellings while keeping a
    final symlink a distinct key. On Windows the parent is resolved with ``abspath`` so junctions and reparse points are
    not followed either.
    )�os�path�split�fspath�joinr��curdir)r��parent�names   r4�
_canonicalr�7sE���7�7�=�=����4��1�L�F�D�
�7�7�<�<��V�%8�r�y�y�9�4�@�@r6c� ��eZdZd�fd�Z�xZS)�_ThreadLocalRegistryc�0��t�|��i|_yr0)�super�__init__�held)r3�	__class__s �r4r�z_ThreadLocalRegistry.__init__Gs���
����)+��	r6r7)r:r;r<r��
__classcell__�r�s@r4r�r�Fs
���,�,r6r�zFinal[_ThreadLocalRegistry]�	_registry�_T�BaseFileLock)�boundc���eZdZUded<ded<ded<dedfdd	d
ddd
dd	dd�																																dd�Z								d�fd�Z�xZS)�FileLockMeta�&WeakValueDictionary[str, BaseFileLock]�
_instancesr
�_instances_lock�set[str]�_instances_under_constructionrTF皙�����?Nr!r$�	rcrdrergrirkrlrmroc	
���t�t|||j��}t|	�}	t	|
�}
t||j|j��}t|
|j|j��}
||||||||	|
|||
d�|�}|s|j||�St|�}|j5|jj|�x}��||jvrd|��}t!|��|j}t#j$�}|j'|�	|j||�}|j)|�t#j$�|k7r
d}t!|��||j|<|cddd�S	ddd�|j+�f||j,f||j.j0f||j2f||j4f||j6f|	|j8f|
|j:f||j<f||j>fd�
}|jA�D���cic]\}\}}||k7r|||f��}}}}|
|jBu}|s|s|Sd}|d	z
}|jA�D]\}\}}|d
|�d|�d|�d
�z
}�|r|d|jB�d|
�d
�z
}tE|��#|j)|�wxYw#1swY��JxYwcc}}}w)N��
stacklevel)�preserve�	supported�cls_name)r�r�)r^r`rbrcrdrergrirkrlrmroz2Singleton lock construction is already active for zOLock construction cannot continue after fork; construct a new lock in the child)
rbr^r`rcrergrirkrlrmzGSingleton lock instances cannot be initialized with differing argumentsz
Non-matching arguments: z
	z (existing lock has z but z was passed)z!
	on_acquired (existing lock has )#�_ensure_current_process�_resolve_lifetime�(_constructor_lifetime_warning_stacklevel�_resolve_context_error_policy�_resolve_close_error_policy�_resolve_preserve_lock_file�_preserve_lock_file_supportedr:�_resolve_on_acquired�_on_acquired_supported�_create_instancer�r�r��getr��RuntimeErrorr��getpidr��discard�is_thread_localr^�_contextr`rcrergrirkrlrm�itemsro�
ValueError)�cls�	lock_filer^r`rbrcrdrergrirkrlrmro�kwargs�params�
singleton_key�instance�msg�construction_registry�construction_pid�params_to_checkr��passed_param�	set_param�non_matching_params�
hook_mismatch�
param_names                            r4rMzFileLockMeta.__call__WsC��$	 �!�$�X�s�s�?k�?k�l�� =�=Q�R��8�9K�L��8�'�3�3T�3T�_b�_k�_k�
��+�;�#�B\�B\�gj�gs�gs�t����(� �(�*� �$8�"4� 0�"4�&�;
��;
����'�'�	�6�:�:�#�9�-�
�
�
 �
 ��N�N�.�.�}�=�=��F� �C�$E�$E�E�N�y�m�\�C�&�s�+�+�(+�(I�(I�%�#%�9�9�;� �%�)�)�-�8�A�"�3�3�I�v�F�H�)�1�1�-�@��9�9�;�"2�2�k�C�&�s�+�+�08����}�-��!!�
 �F�!�&*�8�+C�+C�+E�F���!1�!1�2��8�,�,�1�1�2�!�8�#4�#4�5�+�X�-C�-C�D�!�8�#4�#4�5�%9�8�;X�;X�$Y�#5�x�7R�7R�"S�!1�8�3L�3L� M�#5�x�7R�7R�"S�
��4C�3H�3H�3J�
�3J�/��/�|�Y��y�(�
�<��+�+�3J�	�
�$�8�+?�+?�?�
�"�=��O�W���+�+��5H�5N�5N�5P�1�J�1��y��T�*��%9�)��E�,��Wc�d�d�C�6Q���8��9M�9M�8N�e�T_�S`�`l�m�m�C���o���I*�1�1�-�@��!�
 ��<
s,�9A-K�'J;�9AK�8K�;K�K�Kc
�����t|���jrt�	|�|fi|��St	��fd�|j�D��}|r+|j�ddj|���}t|��t�	|�|fi|j�D��cic]\}}|�jvs�||��c}}��Scc}}w)Nc3��K�|]C\}}|�jvr0�jj|�x��|�jk7r|���Ey�wr0)�accepted_params�default_paramsr�r$)r�r��value�model�	parameters   ��r4r�z0FileLockMeta._create_instance.<locals>.<genexpr>�sU�����
�-���e��5�0�0�0�$�3�3�7�7��=�=�)�F�%�S\�Sd�Sd�Jd�
�-�s�A	Az, does not support non-default lock options: z, )
�_init_parameter_model�accepts_kwargsr�rM�sortedrr:r��	TypeErrorr)
rrr	�unsupportedrr�rrrr�s
       @@�r4r�zFileLockMeta._create_instance�s����&�c�*������7�#�I�8��8�8��
�%�|�|�~�
�
����\�\�N�"N�t�y�y�Yd�Oe�Nf�g�C��C�.� ��w���
�.4�l�l�n�^�n�{�t�U���H]�H]�@]�t�U�{�n�^�
�	
��^s�B<�1B<) r�type[_T]r�str | os.PathLike[str]r^r]r`r_rbrarcrardrarer]rgrfrirhrkrjrlrarmrarornrrXr8r�)rr!rr"r	z'dict[str, _LockInitValue | _ExtraValue]r8r�)r:r;r<rqrrMr�r�r�s@r4r�r�Rs ���6�6���#+�+�
�$�!�e��"�#�!%�3:�/8�!%�#(�48�e�
�e�)�e��e��	e�
�e��e��e��e��e�1�e�-�e��e�!�e�2�e� �!e�"
�#e�N
�
�
�"8�
�Bi�
�	�
�
r6r�zAFinal[WeakKeyDictionary[type[BaseFileLock], _InitParameterModel]]�_INIT_PARAMETER_MODELS�_InitParameterModelc��t�5tj5tj	|�x}��tj|j�jj�}ttd�|D��td�|D��tjt|�j�jj�D��cic].\}}|j t
j"j$ur||��0c}}��}|t|<|cddd�cddd�Scc}}w#1swYnxYwddd�y#1swYyxYw)Nc3�K�|]P}|jtjjtjjhvr|j
���Ry�wr0)�kind�inspect�	Parameter�POSITIONAL_OR_KEYWORD�KEYWORD_ONLYr��r�rs  r4r�z(_init_parameter_model.<locals>.<genexpr>�sF����*�%/�	� �~�~�'�*;�*;�*Q�*Q�SZ�Sd�Sd�Sq�Sq�)r�r��N�N�%/�s�AAc3�hK�|]*}|jtjju���,y�wr0)r'r(r)�VAR_KEYWORDr,s  r4r�z(_init_parameter_model.<locals>.<genexpr>�s)����"o�dn�W`�9�>�>�W�5F�5F�5R�5R�#R�dn�s�02)rrr)�_fork_transition�_FORK_STATE�parameter_models_lockr#r�r(�	signaturer��
parameters�valuesr$�	frozensetr�r�rMrr$r)�empty)rrr3r�rs     r4rr�s��	�	�[�>�>�+�/�/��4�4�E�=� �*�*�3�<�<�8�C�C�J�J�L�J�'� )�*�%/�*�!�
 #�"o�dn�"o�o�,3�+<�+<�T�#�Y�=O�=O�+P�+[�+[�+a�+a�+c� �+c���i� �(�(��0A�0A�0G�0G�G��)�O�+c� ��E�+0�"�3�'��#?�>�	�	�� �?�>��	�	�	�s5�E	�B9D4�3D.�D4�	E	�.D4�4D=	�9E	�	ET)�frozenc�,�eZdZUded<ded<ded<y)r$zfrozenset[str]rrarzdict[str, inspect.Parameter]rN�r:r;r<rqr1r6r4r$r$�s��#�#���0�0r6c�*�|��t|t�st|ttf�s#dt	|�j
��}t
|��|dks%t|t�r%tj|�sd|��}t|��|�?|js3tjd|j
�d|j�d�|��y|�J|j�>|j\}}tj|j
�d	|�d
|�d�t|��|S)ar
    Validate ``lifetime`` and drop a value the backend cannot honor.

    ``lifetime`` is a deliberate age-based lease: a lock file older than ``lifetime`` is broken even while its holder is
    still alive. Existence locks (:class:`SoftFileLock`) implement that behavior by unlinking a reclaimable pathname,
    which can overlap a live holder. A native OS lock lives on the inode, so unlinking the pathname by age cannot revoke
    the kernel lock; a contender would lock a fresh inode and overlap the live holder (#590). Ignore the request with a
    warning rather than accept a setting that breaks mutual exclusion.
    Nz;lifetime must be a finite non-negative number or None, not rz.lifetime must be finite and non-negative, not zlifetime is ignored for z: z2; only SoftFileLock supports lifetime-based expiryr�zH(lifetime=...) uses age-based expiry and can overlap a live holder; use z for expiry or z for fail-closed locking)r�rar_r]r�r:r�math�isfiniter�_lifetime_supported�warnings�warn�_lifetime_unsupported_reason�_lifetime_replacementsr)rgrr�r�strict_lock�leases      r4r�r��s�����h��%�Z��3��,�-O�O�PT�U]�P^�Pg�Pg�Oh�i�C��C�.� ��a�<�J�x��7��
�
�h�@W�B�8�,�O�C��S�/�!���C�$;�$;��
�
�&�s�|�|�n�B�s�7W�7W�6X�Y?�
@�!�	
�
���� :� :� F� �7�7���U��
�
��|�|�n���'���
�5M�
O�'�!�		
��Or6c��|tvrd|��}t|��|dk(r	t�t	d|�S#t$r}d}t|�|�d}~wwxYw)Nz5context_error_policy must be 'chain' or 'group', got r"z]context_error_policy='group' requires Python 3.11+ or the 'exceptiongroup' backport installedrh)r#rry�ImportErrorr)�policyr�excs   r4r�r�sg��
�,�,�E�f�Z�P����o��
���	+� �"��$�f�-�-���	+�q�C��S�/�s�*��	+�s�
5�	A�A�Ac�J�|tvrd|��}t|��td|�S)NzBclose_error_policy must be 'default', 'raise', or 'suppress', got rj)r'rr)rFrs  r4r�r�%s1��
�*�*�R�SY�R\�]����o���"�F�+�+r6c�0�|r|sd|�d�}t|��|S)Nz,preserve_lock_file=True is not supported by z): unlinking its marker is how it releases)r)r�r�r�rs    r4r�r�,s'���	�<�X�J�Fo�p����o���Or6c��|�y|sd|�d�}t|��	t�|S#t$r}d}t|�|�d}~wwxYw)Nz on_acquired is not supported by z.: only native locks expose the lock descriptorz^on_acquired requires Python 3.11+ or the 'exceptiongroup' backport for its rollback error path)rryrE)ror�r�rrGs     r4r�r�5sa������0��
�:h�i����o��'�������'�n����o�3�&��'�s�
$�	A�;�Ac����eZdZUdZded<ded<ded<dZd	ed
<dZded
<dZded<dZd	ed<dZ	ded<dZ
ded<dZded<dZded<dZ
ded<d_�fd�Zed`d��Zdedfddd dd!d"dddd#�																												dad$�Zdbd%�Zedbd&��Zedcd'��Zeddd(��Zded)�Zedbd*��Zedbd+��Zedfd,��Zedgd-��Zedhd.��Zej<did/��Zedbd0��Zej<djd1��Zedhd2��Z e j<dkd3��Z edld4��Z!e!j<dmd5��Z!ednd6��Z"edbd7��Z#dnd8�Z$edbd9��Z%ednd:��Z&dod;�Z'								dpd<�Z(dqd=�Z)d`d>�Z*		drdddd?�											dsd@�Z+e,jZ												dtdA��Z.dudvdB�Z/d`dC�Z0dwdxdD�Z1dwdxdE�Z2d`dF�Z3d`dG�Z4dydH�Z5dzdI�Z6d{dJ�Z7e8d|dK��Z9												d}dL�Z:d~dM�Z;ddN�Z<d`dO�Z=d`dP�Z>d�dQ�Z?d�dR�Z@d`dS�ZAd`dT�ZBd`dU�ZCd`dV�ZDd`dW�ZEddX�ZFd`dY�ZGd`dZ�ZHd`d[�ZI										d�d\�ZJeKd`d]��ZLeKd`d^��ZM�xZNS)�r�a;
    Abstract base class for a file lock object.

    Provides the common reentrant API and state management. Subclasses implement the locking mechanism
    (:class:`UnixFileLock <filelock.UnixFileLock>`, :class:`WindowsFileLock <filelock.WindowsFileLock>`,
    :class:`SoftFileLock <filelock.SoftFileLock>`).

    r�r�r
r�r�r�z FileLock instance in this threadr��_deadlock_holder_descFrar=Nztuple[str, str] | NonerAz4a native OS lock cannot be broken safely by file ager@rPr_r�Tr�r��_serialize_transitionsgr]�_poll_backoff_capc���t�|�di|��t�|_t	�|_t
�|_t|�y)z<Give each lock subclass its own singleton registry and lock.Nr1)	r��__init_subclass__rr�r
r�r�r��_register_fork_class)rrr�s  �r4rPzBaseFileLock.__init_subclass__ws9���
��!�+�F�+�,�.���#�g���,/�E��)��S�!r6c�^�t�|_t�|_t	�|_yr0)rr�r
r�r�r��rs r4rEz$BaseFileLock._reset_class_after_forks ��,�.���#�g���,/�E��)r6rr�r!r$r�c	�0�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:`SoftFileLock`, 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:`FileLock`) 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: what to do with an ``os.close`` failure after relinquishing descriptor ownership.
            ``"default"`` keeps each backend's historical behavior (Unix native locks drop a FUSE/Docker ``EIO``;
            Windows native locks and :class:`SoftFileLock` propagate); ``"raise"`` always propagates the ``OSError``;
            ``"suppress"`` always ignores it. Held state is released either way. It does not affect unlock failures or
            lock-file deletion.
        :param fallback_to_soft: for :class:`UnixFileLock`, whether to switch to :class:`SoftFileLock` when the
            filesystem's ``flock`` returns ``ENOSYS``. ``True`` (the default) keeps the historical fallback;
            ``False`` fails closed, letting the ``ENOSYS`` propagate so a caller that needs kernel-enforced
            locking is never silently downgraded. It has no effect on Windows or :class:`SoftFileLock`.
        :param preserve_lock_file: for native locks (:class:`FileLock`), whether filelock promises not to unlink the
            lock pathname on release. ``False`` (the default) keeps each backend's cleanup: Windows removes the lock
            file, Unix already leaves it. ``True`` keeps a stable file identity for ACLs, auditing, and holder metadata:
            Windows skips its post-release unlink and Unix refuses to enter the ``ENOSYS`` soft fallback (which releases
            by unlinking). :class:`SoftFileLock` rejects ``True``. The promise covers filelock's own release path only;
            it cannot stop another process or the filesystem from removing the pathname.
        :param on_acquired: for native locks (:class:`FileLock`), a callable invoked with the borrowed lock descriptor
            once per physical acquisition, after filelock holds the native lock and finished backend initialization but
            before :meth:`~BaseFileLock.acquire` returns. Recursive acquisitions do not call it again. The callback may
            read, write, seek, truncate, or set metadata through ``os`` on the descriptor, but must not close, unlock,
            or take ownership of it, and filelock does not fsync its writes. If it raises, filelock releases the lock
            and re-raises. :class:`SoftFileLock` rejects the hook.

        )rr^r`rcrergN)r�r�_creator_pidr
�_transition_lock�_is_thread_local�
_is_singleton�_context_error_policy�_close_error_policy�_fallback_to_soft�_preserve_lock_file�_on_acquired�ThreadLocalFileContext�FileLockContextr�r�_register_fork_object)r3rr^r`rbrcrdrergrirkrlrmros              r4r�zBaseFileLock.__init__�s���L�I�I�K��� %���� ,���)���%9��"�#5�� �!1���#5�� �'���*e�L�*@�Ve��i�i�	�*����'��
*
��
�	�d�#r6c��|jS)z?:returns: a flag indicating if this lock is thread local or not)rWr2s r4rzBaseFileLock.is_thread_local�s���$�$�$r6c��|jS)zh
        A flag indicating if this lock is singleton or not.

        .. versionadded:: 3.13.0

        )rXr2s r4rdzBaseFileLock.is_singleton�s���!�!�!r6c��|jS)z�
        How a context manager reconciles a body failure with a release failure on exit.

        .. versionadded:: 3.30.0

        )rYr2s r4riz!BaseFileLock.context_error_policy�s���)�)�)r6c��|jS)z�
        What a lock does with an ``os.close`` failure after relinquishing descriptor ownership.

        .. versionadded:: 3.30.0

        )rZr2s r4rkzBaseFileLock.close_error_policy�s���'�'�'r6c��	tj|�y#t$r$|jdk(s|jdk(r|rYy�wxYw)Nr&r$)r��close�OSErrorrZ)r3�fd�default_suppressess   r4�_close_released_fdzBaseFileLock._close_released_fdsF��	��H�H�R�L���	��'�'�:�5�$�:R�:R�V_�:_�dv���	�s��)A�Ac��|jS)a:
        Whether a :class:`FileLock` falls back to :class:`SoftFileLock` when the filesystem lacks ``flock``.

        Only :class:`UnixFileLock` acts on it: when ``False`` an ``ENOSYS`` from ``flock`` propagates instead of
        switching to existence-lock semantics.

        .. versionadded:: 3.30.0

        )r[r2s r4rlzBaseFileLock.fallback_to_softs���%�%�%r6c��|jS)aG
        Whether filelock promises not to unlink the lock pathname on release.

        When ``True``, Windows skips its post-release unlink and Unix refuses the ``ENOSYS`` soft fallback.
        :class:`SoftFileLock` rejects ``True`` because unlinking its marker is how it releases.

        .. versionadded:: 3.30.0

        )r\r2s r4rmzBaseFileLock.preserve_lock_files���'�'�'r6c��|jS)av
        The callback run with the borrowed lock descriptor once per physical acquisition, or ``None``.

        Native locks only. It runs after the native lock is held and backend initialization finished, before
        :meth:`~BaseFileLock.acquire` returns; a raise rolls back the acquisition. :class:`SoftFileLock` rejects it.

        .. versionadded:: 3.30.0

        )r]r2s r4rozBaseFileLock.on_acquired%s��� � � r6c�.�|jjS)zPath to the lock file.)rrr2s r4rzBaseFileLock.lock_file2s���}�}�&�&�&r6c�.�|jjS)zZ
        The default timeout value, in seconds.

        .. versionadded:: 2.0.0

        )rr^r2s r4r^zBaseFileLock.timeout7s���}�}�$�$�$r6c�8�t|�|j_y)ze
        Change the default timeout value.

        :param value: the new value, in seconds

        N)r]rr^�r3rs  r4r^zBaseFileLock.timeoutAs��!&�e���
�
�r6c�.�|jjS)z\
        Whether the locking is blocking or not.

        .. versionadded:: 3.14.0

        �rrcr2s r4rczBaseFileLock.blockingKs���}�}�%�%�%r6c�&�||j_y)zb
        Change the default blocking value.

        :param value: the new value as bool

        Nrsrqs  r4rczBaseFileLock.blockingUs��"'��
�
�r6c�.�|jjS)z^
        The default polling interval, in seconds.

        .. versionadded:: 3.24.0

        �rrer2s r4rezBaseFileLock.poll_interval_s���}�}�*�*�*r6c�&�||j_y)zh
        Change the default polling interval.

        :param value: the new value, in seconds

        Nrvrqs  r4rezBaseFileLock.poll_intervalis��',��
�
�#r6c�.�|jjS)aY
        The soft marker age in seconds that permits expiry, or ``None`` to disable age-based expiry.

        A non-``None`` value permits a waiter to enter while the previous holder remains active, so it does not provide
        strict mutual exclusion. Native locks ignore the value with a warning.

        .. versionadded:: 3.24.0

        )rrgr2s r4rgzBaseFileLock.lifetimess���}�}�%�%�%r6c�P�t|t|�d��|j_y)a!
        Change the legacy age-based expiry threshold.

        :param value: the new value in seconds, or ``None`` to disable expiration

        :raises ValueError: if *value* is negative or not finite
        :raises TypeError: if *value* is not ``None`` and not a real number

        rPr�N)r�r�rrgrqs  r4rgzBaseFileLock.lifetime�s��"3�5�$�t�*�QR�!S��
�
�r6c�l�|jjtk(rdS|jjS)z&The file permissions for the lockfile.i��rr`rr2s r4r`zBaseFileLock.mode�s+���
�
�*�*�.>�>�u�V�D�M�M�DV�DV�Vr6c�<�|jjtk7S)z1Whether the file permissions were explicitly set.r{r2s r4�has_explicit_modezBaseFileLock.has_explicit_mode�s���}�}�!�!�%5�5�5r6c�l�|jjtk(rdS|jjS)z]Mode for ``os.open``: 0o666 when unset so umask and ACLs decide, otherwise the explicit mode.i�r{r2s r4�
_open_modezBaseFileLock._open_mode�s)���
�
�*�*�.>�>�u�V�D�M�M�DV�DV�Vr6c�F�t�|jjduS)z�
        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)r�r�lock_file_fdr2s r4�	is_lockedzBaseFileLock.is_locked�s��	 �!��}�}�)�)��5�5r6c�B�t�|jjS)zGThe number of times this lock has been acquired (but not yet released).)r�r�lock_counterr2s r4r�zBaseFileLock.lock_counter�s��	 �!��}�}�)�)�)r6c�&�|j�|S)zG
        Acquire the lock.

        :returns: the lock object

        )�acquirer2s r4�	__enter__zBaseFileLock.__enter__�s��	
�����r6c�&�|j|�y)zgRelease the lock, reconciling a release failure with any body failure per :attr:`context_error_policy`.N)�_release_in_context�r3�exc_type�	exc_value�	tracebacks    r4�__exit__zBaseFileLock.__exit__�s��	
� � ��+r6c��	|j�y#t$r(}|�|jdk(r�t||�Yd}~yd}~wwxYw)Nr!)�releaser�rYr�)r3r�r�s   r4r�z BaseFileLock._release_in_context�sC��	?��L�L�N���	?��!�T�%?�%?�7�%J��#�J�
�>�>��	?�s��	A�?�Ac���t|�jd�tj�k7ryt	j
t�5|jd��ddd�y#1swYyxYw)z=Force-release so a dropped reference never leaks a held lock.rUNT)�force)�varsr�r�r�
contextlibr&�	Exceptionr�r2s r4�__del__zBaseFileLock.__del__�sJ����:�>�>�.�)�R�Y�Y�[�8���
 �
 ��
+��L�L�t�L�$�,�
+�
+�s�
A&�&A/)�poll_intervallrc�cancel_checkc��|j�|�|jj}|�|jj}|� d}t	j
|td��|}|�|n|jj}tj�}|j|||||��5|jxjdz
c_t|j�}|j|||��	|j|||||��|j%|�t'|��cddd�S#t $r|j#|��wxYw#1swYyxYw)	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, ``None`` means use the default
            :attr:`~poll_interval`
        :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.
        :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()

        .. 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�r�)rcr�r^re�
start_timer)r^rc��lock)�_raise_if_inheritedrr^rcr>r?�DeprecationWarningre�time�perf_counter�_transition_admissionr�r�r�_raise_if_would_deadlock�_poll_until_acquiredr��_reconcile_failed_acquire�_commit_acquire�AcquireReturnProxy)	r3r^rer�rcr�rr��	canonicals	         r4r�zBaseFileLock.acquire�sS��Z	
� � �"��?��m�m�+�+�G����}�}�-�-�H��%�?�C��M�M�#�1�a�@�*�M�)6�)B�
��
�
�Hc�Hc�
��&�&�(�
��
'�
'��%��'�!�(�
�
�M�M�&�&�!�+�&�"�4�>�>�2�I��)�)�)�W�x�)�X�

��)�)�%�!-�#�"/�)�*��
� � ��+�%�4�0�3
�
��*!�
��.�.�y�9��
��+
�
�s%�'A	E�1D-�E�-E	�	E�Ec#�K�|jr|jrd��y|jjd��s�|r	|�|�rt	|j
��|dk\r/t
j�|z
|k\rt	|j
��t
j|�|jjd��s��	d��|jj�y#|jj�wxYw�w)NF)rcr)
rMrWrVr�rrr�r��sleepr�)r3rcr�r^rer�s      r4r�z"BaseFileLock._transition_admission.s������*�*�d�.C�.C����'�'�/�/��/�?��� 8�\�^��d�n�n�-�-��!�|�� 1� 1� 3�j� @�G� K��d�n�n�-�-��J�J�}�%��'�'�/�/��/�?�	,���!�!�)�)�+��D�!�!�)�)�+�s�B?D�C"�D�"C>�>Dc��|jxr
|j}|r|jntj�5|j
t
j�k7s|js
	ddd�y|sB|jjdkDr)|jxjdzc_
	ddd�yt|�|j}}tjd||�	|j�|j#�tjd||�ddd�y#t $r|js|j#��wxYw#1swYyxYw)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.

        Nrz#Attempting to release lock %s on %szLock %s released on %s)rMrWrVr��nullcontextrUr�rr�rr�r�rrT�debug�_release_with_fork_trackingr��_commit_release)r3r��	serialize�lock_id�
lock_filenames     r4r�zBaseFileLock.releaseIs#���/�/�M��8M�8M�4M�	�&/�T�
"�
"�Z�5K�5K�5M�
M�� � �B�I�I�K�/�t�~�~��N�
M��T�]�]�7�7�!�;��
�
�*�*�a�/�*��N�
M�&(��X�t�~�~�]�G��M�M�?��-�X�
��0�0�2�
� � �"��M�M�2�G�]�K�'N�
M��!�
��~�~��(�(�*��

��N�
M�s/�/E�6;E�:.E�)D)�9'E�)'E�E�Ec��|jtj�k7r0t|�j�d|j
�d�}t
|��y)Nz on z4 was inherited across fork; construct a new instance)rUr�rr�r:rr�)r3rs  r4r�z BaseFileLock._raise_if_inheritedisI������	�	��+��$�Z�(�(�)��d�n�n�-=�=q�r�C��s�#�#�,r6c��d|j_d|j_||j_||j_yr0�r�pending_lock_file_fd�pending_lock_file_fd_identityr��lock_file_fd_identity�r3rh�identitys   r4�_mark_descriptor_ownedz#BaseFileLock._mark_descriptor_ownedns2��-1��
�
�*�6:��
�
�3�%'��
�
�"�.6��
�
�+r6c�H�||j_||j_yr0)rr�r�r�s   r4�_mark_descriptor_pendingz%BaseFileLock._mark_descriptor_pendingts��-/��
�
�*�6>��
�
�3r6c��d|j_d|j_d|j_d|j_yr0r�r2s r4�_mark_descriptor_releasedz&BaseFileLock._mark_descriptor_releasedxs2��-1��
�
�*�6:��
�
�3�%)��
�
�"�.2��
�
�+r6c�T�t�|_d|j_d|j_d|j_d|j_d|j_d|j_d|j_	d|j_
d|j_y)Nr1r)r
rVr�owner_claim_paths�
claim_rootr��lock_file_fd_tokenr�r�r�r��
lock_file_keyr2s r4r5z'BaseFileLock._reset_after_fork_in_child~sx�� %����*,��
�
�'�#'��
�
� �%)��
�
�"�+/��
�
�(�.2��
�
�+�-1��
�
�*�6:��
�
�3�%&��
�
�"�&*��
�
�#r6c��g}|jj�Q|jj�;|j|jj|jjf�|jj
�;|j|jj
|jjf�t|�Sr0)rr�r�r�r�r�r��tuple)r3�descriptorss  r4r@z"BaseFileLock._descriptors_for_fork�s���@B���=�=�%�%�1�d�m�m�6V�6V�6^�����
�
� :� :�D�M�M�<_�<_�`�a��=�=�-�-�9�����
�
� B� B�D�M�M�Do�Do�p�q��[�!�!r6c�t�|jjdk(xr|jxr	|dkxr|}|r�tjj|j
|��dt|�hvrG|jxjdzc_d|j�d|j�d�}t|��yy)a^
        Fail fast when a *different* live instance already holds this path in the current deadlock scope.

        Only the first, indefinitely-blocking acquire can self-deadlock this way: waiting in the OS primitive would
        block on a lock this flow already owns. A finite timeout or ``blocking=False`` keeps the normal Timeout path.
        rrNzDeadlock: lock 'z!' is already held by a different zE. Use is_singleton=True to enable reentrant locking across instances.)rr�r�r�r�r��
_registry_keyr�rrLr�)r3r�r^rc�would_blockrs      r4r�z%BaseFileLock._raise_if_would_deadlock�s����m�m�0�0�A�5�i�d�n�n�:L�i�QX�[\�Q\�i�ai���9�>�>�-�-�d�.@�.@��.K�L�UY�[]�^b�[c�Td�d��M�M�&�&�!�+�&�"�4�>�>�"2�2S�TX�Tn�Tn�So�pV�W�
��s�#�#�
e�;r6c�2�|j�x}�|S||fSr0)�_deadlock_scope)r3r��scopes   r4r�zBaseFileLock._registry_key�s&��&*�&:�&:�&<�<�U�E�y�]�E�S\�K]�]r6c��y)aX
        Execution unit whose own hold would deadlock a new acquire.

        ``None`` scopes holders to the thread, which the thread-local registry already separates. Async locks
        override it with the running task, since one event loop thread runs many tasks and only a reacquire from
        the *same* task can self-deadlock.
        Nr1r1r6r4r�zBaseFileLock._deadlock_scope�s��r6c��t|�}|j}d}	|j�|jsG|j	�t
j
d||�|j�|j�|jrt
j
d||�y|j||||��rt|��|dz
}|j||�}	d}
t
j
|
|||	�tj|	���)Nrz#Attempting to acquire lock %s on %szLock %s acquired on %s)rcr�r^r�rz2Lock %s not acquired on %s, waiting %s seconds ...)
r�rr�r��_try_break_expired_lockrTr��_acquire_with_fork_tracking�_check_give_upr�_poll_delayr�r�)r3rcr�r^rer�r�r��attempt�delayrs           r4r�z!BaseFileLock._poll_until_acquired�s����T�(�����
�����$�$�&��>�>��,�,�.��
�
�C�W�m�\��0�0�2��(�(�*��~�~��
�
�6���O���"�"�!�)��%�	#���m�,�,��q�L�G��$�$�]�G�<�E�F�C��M�M�#�w�
�u�=��J�J�u��+r6c	���|js|St|j|dt|t�zz�}t|t	j
t
|dz�dz�dz�S)Nr�i@Br)rN�minr �max�secrets�	randbelowr_)r3rer��windows    r4r�zBaseFileLock._poll_delay�sk���%�%� � ���"�"�M�A��W�F[�9\�4\�$\�
���=�'�"3�"3�C���8J�4K�a�4O�"P�S\�"\�]�]r6c�`�|jr|j|�y|j�yr0)r�r��
_undo_acquire)r3r�s  r4r�z&BaseFileLock._reconcile_failed_acquire�s%���>�>�� � ��+���� r6c�n�|j�|jjdk7ry	|jtd|jj��y#t
$rS}|j}	|j�||_�#t
$r}t||�Yd}~||_�d}~wwxYwd}~wwxYw)Nrr_)	r]rr�rr�r�r�r�r�)r3�callback_error�callback_contextr�s    r4�_invoke_on_acquiredz BaseFileLock._invoke_on_acquired�s������$��
�
�(B�(B�a�(G��		����d�5�$�-�-�*D�*D�E�F���	�-�9�9��
G��0�0�2�*:�N�&���!�
G�'��
�F�F�)9�N�&���
G��		�sA�/A�	B4�!B/�.B�>B/�	B,�B'�B/�'B,�,B/�/B4c�P�t|�5	|j�	|j	�	ddd�|jr|j�yy#t$r}|j|��d}~wwxYw#t$r}|j|��d}~wwxYw#1swY�mxYwr0)r/�_acquirer��_rollback_failed_acquire�_register_context_descriptor�_rollback_failed_registrationr�r�)r3�acquisition_error�registration_errors   r4r�z(BaseFileLock._acquire_with_fork_tracking�s���
�d�
#�
��
�
��
��1�1�3�$��>�>��$�$�&���!�
��-�-�.?�@���
��
!�
��2�2�3E�F���
��$�
#�sE�B�A�A9�	A6�A1�1A6�6B�9	B�B�B�B�B%c�Z�|jsyd}d}	|j�	|j	�|�td|||�yy#t$r6}|}	|j�n#t$r}|}Yd}~nd}~wwxYwYd}~�]d}~wwxYw#t$r}td||||�Yd}~�qd}~wwxYw)Nzlock acquisition cleanup failed)r�r�r��'_register_unverified_context_descriptorr�r�)r3r�r��tracking_errorr��rollback_errors      r4r�z%BaseFileLock._rollback_failed_acquires����~�~��37��/3��	'��-�-�/�		��,�,�.��)�!�1�3D�FX�Zh�
�*��#�	'�!&��
'��<�<�>�� �
'�!&���
'���	'���	�!�1�!�"���
�
��	�sX�A�B�	B�B�A#�"B�#	A8�,A3�.B�3A8�8B�B�	B*�B%�%B*c���d}	|j�	|j�|�td||�yy#t$r}|}Yd}~�2d}~wwxYw#t$r}td|||�Yd}~�Ed}~wwxYw)Nz&descriptor registration cleanup failed)r�r�r�r�)r3r�r�r�r�s     r4r�z*BaseFileLock._rollback_failed_registration%s���/3��	#��8�8�:�	��,�,�.�
�%�!�"J�L^�`n�o�&���	#�"�N��	#���	�!�8�:L�n�^l�
�
��	�s+�6�A�	A�A�A�	A/�A*�*A/c��t|�5	|j�|j�	ddd�y#|j�wxYw#1swYyxYwr0)r/�_release�_unregister_released_descriptorr2s r4r�z(BaseFileLock._release_with_fork_tracking5sE��
�d�
#�
7��
�
���4�4�6�	$�
#���4�4�6��	$�
#�s�A
�8�A
�A
�
A
�
Ac���|jj�[|jj�Dt|jj|jj�|j_yyyr0)rr�r��_register_owned_descriptorr�r2s r4r�z)BaseFileLock._register_context_descriptor<sU���=�=�%�%�1�d�m�m�6V�6V�6^�/I��
�
�*�*��
�
�3�3�0�D�M�M�,�7_�1r6c��|jj�F|jj�/t|jj�|j_yyyr0)rr�r��%_register_unverified_owned_descriptorr2s r4r�z4BaseFileLock._register_unverified_context_descriptorCsH���=�=�%�%�1�d�m�m�6V�6V�6^�/T�UY�Ub�Ub�Uo�Uo�/p�D�M�M�,�7_�1r6c��|jj�F|jjx}�t|�d|j_d|j_yyr0)rr�r��_unregister_owned_descriptorr�)r3�tokens  r4r�z,BaseFileLock._unregister_released_descriptorHsL���=�=�%�%�-����9�9�9��F�,�U�3�/3�D�M�M�,�26�D�M�M�/�	.r6c��td|jjdz
�|j_|jjdk(r|j�yy)zfRoll back the counter after a failed acquire, dropping the registry entry once nothing holds the path.rrN)r�rr��_drop_registry_entryr2s r4r�zBaseFileLock._undo_acquireOsG��%(��D�M�M�,F�,F��,J�%K��
�
�"��=�=�%�%��*��%�%�'�+r6c��|jjdk(r?|j|�}||j_t	|�t
j|<yy)zeRecord this instance as the holder once the first acquire succeeds, so peers can detect the deadlock.rN)rr�r�r�r�r�r�)r3r��keys   r4r�zBaseFileLock._commit_acquireUsG���=�=�%�%��*��$�$�Y�/�C�*-�D�M�M�'�"$�T�(�I�N�N�3��	+r6c��|jj}d|j_|�!tjj	|d�yy)zIForget the key owned by this hold without resolving a mutable path again.N)rr�r�r�r�)r3r�s  r4r�z!BaseFileLock._drop_registry_entry]s;���m�m�)�)��&*��
�
�#��?��N�N���s�D�)�r6c�F�d|j_|j�y)zdRecord the lock as fully released: reset the recursion counter and drop the deadlock-registry entry.rN)rr�r�r2s r4r�zBaseFileLock._commit_releaseds��%&��
�
�"��!�!�#r6c��|jjx}�ytjt�5tj|j�}tj�|jz
|kr
	ddd�yt|j|j|j�ddd�y#1swYyxYw)zVRemove the lock file if its modification time exceeds the configured :attr:`lifetime`.N)rrgr�r&rgr��lstatrr��st_mtimer�st_ino)r3rg�sts   r4r�z$BaseFileLock._try_break_expired_lockis����
�
�.�.�.�H�7��
�
 �
 ��
)�
���$�.�.�)�B��y�y�{�R�[�[�(�8�3��*�
)�
�D�N�N�B�K�K����C�*�
)�
)�s�AB5�+B5�5B>c�"�t|�|j}}|durtjd||�y|�|�rtjd||�yd|cxkrt	j
�|z
krnytjd||�yy)NFz+Failed to immediately acquire lock %s on %sTz(Cancellation requested for lock %s on %srz"Timeout on acquiring lock %s on %s)r�rrTr�r�r�)r3rcr�r^r�r�r�s       r4r�zBaseFileLock._check_give_upws���"$�D��4�>�>����u���M�M�G��R_�`���#����M�M�D�g�}�]����:�$�+�+�-�
�:�:��
�M�M�>���W��r6c��t�)zjIf the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file.��NotImplementedErrorr2s r4r�zBaseFileLock._acquire��
��"�!r6c��t�)z>Releases the lock and sets self._context.lock_file_fd to None.rr2s r4r�zBaseFileLock._release�rr6)rrZr8r9r7)rr"r^r]r`r_rbrarcrardrarer]rgrfrirhrkrjrlrarmrarornr8r9)r8ra)r8rh)r8rj)rhr_rirar8r9)r8rnr�)r8r])rzfloat | strr8r9)rrar8r9)rr]r8r9)r8rf)rrfr8r9)r8r_)r8rR�r�ztype[BaseException] | Noner��BaseException | Noner�zTracebackType | Noner8r9)r�r
r8r9)NN)r^rfrerfr�rfrczbool | Noner��Callable[[], bool] | Noner8r�)rcrar�rr^r]rer]r�r]r8�Generator[None])F)r�rar8r9r0)rhr_r��tuple[int, int] | Noner8r9rA)r�r�r^r]rcrar8r9)r�r�r8r)r8�Hashable | None)rcrar�rr^r]rer]r�r]r8r9)rer]r�r_r8r])r�r�r8r9)r�r�r8r9)r�r�r8r9)
rcrar�rr^r]r�r]r8ra)Or:r;r<rprqrLr=rAr@r�r�r�rMrNrP�classmethodrErr�rr�rdrirkrjrlrmrorr^�setterrcrergr`r}rr�r�r�r�r�r�r�r�rr�r�r�r�r�r�r5r@r�r��staticmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�s@r4r�r�Is@����7�6���#+�+�"D��3�C�!&���%�6:��2�9�)_� �#�^�56�,�c�5�+/�!�4�.�$(��D�'�$)��D�(� #��u�"�"��2��2��$�!�X$��"�#�!%�3:�/8�!%�#(�48�X$�)�X$��X$��	X$�
�X$��X$��X$��X$��X$�1�X$�-�X$��X$�!�X$�2�X$� 
�!X$�t%��"��"��*��*��(��(���
&��
&��
(��
(��
!��
!��'��'��%��%�
�^�^�-��-��&��&��_�_�'��'��+��+����,��,��
&��
&��_�_�
T��
T��W��W��6��6�W��
6��
6��*��*�
�,�,�,�(�,�(�	,�

�,�?�%�!%�&*�W1�
(,� $�26�W1��W1�$�W1�
%�W1��
W1�0�W1�
�W1�r���,��,�0�	,�
�,��
,��,�
�,��,�4L�@$�
7�?�3�+�"�$� ^�����!��!�0�	!�
�!��
!��!�
�!�F^�!�
�
'��:p� 7��q�
7�(�+�*�$�
D����0�	�
���
�
��(�"��"��"��"r6)�	metaclassc�8�eZdZdZdd�Zdd�Z								dd�Zy)	r�zDA context-aware object that will release the lock file when exiting.c��||_yr0r�)r3r�s  r4r�zAcquireReturnProxy.__init__�s	��FJ��	r6c��|jSr0r�r2s r4r�zAcquireReturnProxy.__enter__�s���y�y�r6c��t|jt�r|jj|�y|jj	�yr0)r�r�r�r�r�r�s    r4r�zAcquireReturnProxy.__exit__�s4���d�i�i��.��I�I�)�)�)�4��I�I���r6N)r��0BaseFileLock | ReadWriteLock | SoftReadWriteLockr8r9)r8rr	)r:r;r<rpr�r�r�r1r6r4r�r��s;��N�K��	 �,�	 �(�	 �(�		 �

�	 r6r�c���eZdZUdZded<ded<ded<ded	<ded
<dZded
<dZded<dZded<dZded<dZ	ded<dZ
ded<dZded<dZded<dZ
ded<dZded<y)r_z0Holds the context for a ``BaseFileLock`` object.r�rr]r^r_r`rarcreNrfrg�
int | Noner�r�r
r�r�r�rr�rr�r1ztuple[str, ...]r�z
str | Noner�)r:r;r<rprqrgr�r�r�r�r�r�r�r�r�r1r6r4r_r_�s���:��N�
�N�

�I��N���"�H�l�!� $�L�*�#�&*��
�)�59��1�8�(,��*�+�=A�!�#9�@��L�#��&*�M�?�)�*,���+�"�J�
�!r6r_c��eZdZdZy)r^z8A thread local version of the ``FileLockContext`` class.N)r:r;r<rpr1r6r4r^r^�s��Br6r^c�6�eZdZUded<ded<ded<ded<y)�_OwnedDescriptorr_rh�creator_pidr�device�inodeNr9r1r6r4rr�s���G������r6rc��eZdZUdZded<y)�_ForkTransitionContextrr_�depthN)r:r;r<r"rqr1r6r4r!r!�s���E�3�Nr6r!c��eZdZdd�Zdd�Zy)�
_ForkStatec�"�tt��|_t�|_t�|_t�|_i|_d|_d|_	i|_
i|_i|_i|_
tj�|_y�NrF)rr
�gate�
registry_lockr1r!�transition_context�transitions�active_transitions�admission_closed�fork_owner_depths�pinned_objects�pinned_classes�provisional_descriptor_tokensr�r�pidr2s r4r�z_ForkState.__init__�st���e�g�&��	�"�W���%*�W��"�"8�":���NP���"#��� %���13���LN���QS���OQ��*��9�9�;��r6c���tt��|_t�|_t�|_t�|_i|_d|_d|_	i|_
i|_i|_i|_
yr&)rr
r'r(r1r!r)r*r+r,r-r.r/r0r2s r4�reset_synchronizationz _ForkState.reset_synchronization�sg���e�g�&��	�"�W���%*�W��"�"8�":������"#��� %���!#��� ��� ���-/��*r6Nr7)r:r;r<r�r3r1r6r4r$r$�s���0r6r$z0Final[WeakValueDictionary[int, _ForkResettable]]�
_FORK_OBJECTSz5Final[WeakValueDictionary[int, _ForkResettableClass]]�
_FORK_CLASSESz"Final[dict[int, _OwnedDescriptor]]�_OWNED_DESCRIPTORSzFinal[count[int]]�_DESCRIPTOR_TOKENS�_TRANSITION_TOKENSrr0zos.forkz
os.forkpty�_FORK_AUDIT_EVENTSc�x�t�ytjt�ttt
t��y)NrH)rVru�addaudithook�_audit_fork_safety�_pin_fork_objects�_resume_parent_after_fork�_reset_child_after_forkr1r6r4�_register_fork_hooksr@s+��� �����'�(�� �1�.�r6c#�K�tsd��yt�tj�}t	|�}	d��tj�|k(rt|�yy#tj�|k(rt|�wwxYw�wr0)rWr�r�r�_enter_fork_transition�_leave_fork_transition)�descriptor_ownerrr�s   r4r/r/si���� �
�����)�)�+�K�"�#3�4�E�*�
�
�9�9�;�+�%�"�5�)�&��2�9�9�;�+�%�"�5�)�&�s�5B�A �$B� %B�Bc���tsyt�5tj5|tt|�<t
�ddd�ddd�y#1swY�xYw#1swYyxYwr0)rWr/r0r(r4r��_refresh_owner_pins)rs r4r`r`)sC�� ��	�	�[�6�6�&.�
�b��l�#���7�	�	�6�6��	�	��"�A�A�A�A	�A�A&c���tsyt�5tj5|tt|�<t
�ddd�ddd�y#1swY�xYw#1swYyxYwr0)rWr/r0r(r5r�rFrSs r4rQrQ1sC�� ��	�	�[�6�6�!$�
�b��g����7�	�	�6�6��	�	�rGc���tsyt�5|�-tj|�}|j|j
f}t
||�cddd�S#1swYyxYwr0)rWr/r��fstat�st_devr�_record_owned_descriptor�rhr��stat_results   r4r�r�9sM�� ��	�	����(�(�2�,�K�"�)�)�;�+=�+=�=�H�'��H�5�	
�	�	�s�;A�A c�h�tsyt�5t|d�cddd�S#1swYyxYwr0)rWr/rL)rhs r4r�r�Cs$�� ��	�	�'��D�1�
�	�	�s�(�1c���tj5tt�}t	|tj�|�dn|d|�dn|d��t|<ddd�|S#1swYSxYw)Nrr�rhrrr)r0r(�nextr7rr�rr6)rhr�r�s   r4rLrLJsg��	�	"�	"��'�(��$4���	�	��#�+�4��!��"�*�$����	%
��5�!�
#��L�
#��L�s�AA!�!A+c��t�5tj5tj	|d�ddd�ddd�y#1swY�xYw#1swYyxYwr0)r/r0r(r6r�)r�s r4r�r�Vs9��	�	�[�6�6����u�d�+�7�	�	�6�6��	�	�s!�A�A�A�A
	�	A�Ac��t�t�}tj5tjj|d�dztj|<dt_tjttjj|d��kDrYtjj�tjttjj|d��kDr�Yttjj|i�j��}ddd�t�D�cic]}|��t|�|��}}ttt d�|j�D���}tj"5tj$j'|g�j)|�tj*j'|g�j)tt,j���tj.j'|g�j)tt0j���ddd�y#1swY��;xYwcc}w#1swYyxYw)NrrTr1c3�JK�|]}|j�D]}|����y�wr0)r@)r��owner�
descriptors   r4r�z$_pin_fork_objects.<locals>.<genexpr>is#����e�_�E�u�Gb�Gb�Gd��Z�Gd�Z�_�s�!#)r�rr0r'r-r�r,r+r�r*�waitr�r4�_verify_unverified_descriptorsr�r�_snapshot_descriptor_for_forkr(r0�
setdefaultr�r.r4r/r5)�	thread_id�transition_ownersrV�ownersr0s     r4r=r=[s�������I�	�	�	�3>�3P�3P�3T�3T�U^�`a�3b�ef�3f��%�%�i�0�'+��$��,�,�s�;�3J�3J�3N�3N�y�Z\�3]�/^�^����!�!�#��,�,�s�;�3J�3J�3N�3N�y�Z\�3]�/^�^�!�+�"9�"9�"=�"=�i��"L�"S�"S�"U�V��
�#�$�,=�
S�,=�5��AR�b��i���,=�F�
S�$)��)�e�V�]�]�_�e�	
�%�!�
�	"�	"��1�1�<�<�Y��K�R�R�Sp�q��"�"�-�-�i��<�C�C�E�-�J^�J^�J`�Da�b��"�"�-�-�i��<�C�C�E�-�J^�J^�J`�Da�b�
#�	"�
�	��T�
#�	"�s+�CI(�87I(�I5�
I5�CI:�(I2�:Jc�:�t�}tj5tj|j	�D]}t
j	|d��tj|j	�tj|j	�tj|s3tj|=tj|=tj|=ddd�tj5tj|dk(rtj|=ntj|xxdzcc<ttj�t_tjj�ddd�y#1swY��xYw#1swYyxYw�Nr)
rr0r(r0r�r6r.r/r'r-rar,�
notify_all)r\r�s  r4r>r>rs-����I�	�	"�	"� �>�>�y�I�M�M�O�E��"�"�5�$�/�P��"�"�9�-�1�1�3��"�"�9�-�1�1�3��8�8��C��9�9�)�D��*�*�9�5��*�*�9�5�
#�
�	�	��(�(��3�q�8��-�-�i�8��)�)�)�4��9�4�'+�K�,I�,I�'J��$����#�#�%�

�	�
#�	"��
�	�s�CF�8BF�F�Fc��t�yr0)r?r1r6r4r�r��s���r6c�.�tj�x}tjk(ryt	�}tj
j
|dg�d}tjj
|dg�d}g}ttj��D]9\}}|j|k7s�|jtj|���;tj�|t_tj!�t#|||�y)Nr1r)r�rr0r1rr.r�r/r�r6rrr�r�r3r#�clear�_detach_child_state)r1r\r.r/r�r�rWs       r4r?r?�s����y�y�{���{���.����I� �/�/�3�3�I��t�D�R�H�N� �/�/�3�3�I��t�D�R�H�N�*,�K�"�#5�#;�#;�#=�>���z��!�!�S�(����1�5�5�e�<�=�?��%�%�'��K�O�� � �"���^�^�Dr6c�N�t�}tj5tjrw|tjvre|tj
vrStjj
�tjr%|tjvr|tj
vr�Stt�}|tj
j|i�|<txjdz
c_
ddd�tjxjdz
c_S#1swY�.xYwr`)
rr0r'r,r-r*rXrRr8r[r+r)r")rDr\r�s   r4rBrB�s�����I�	�	�	��(�(���!>�!>�>���!8�!8�8����!�!�#�	
�(�(���!>�!>�>���!8�!8�8��'�(��CS����*�*�9�b�9�%�@��&�&�!�+�&�
��"�"�(�(�A�-�(��L�
�	�s�BD�#AD�D$c��tjxjdzc_tj5t	�}tj
||=tj
|stj
|=txjdzc_tjj�ddd�y#1swYyxYwr`)r0r)r"r'rr*r+ra)r�r\s  r4rCrC�s����"�"�(�(�A�-�(�	�	�	��K�	��#�#�I�.�u�5��&�&�y�1��'�'�	�2��&�&�!�+�&����#�#�%�

�	�	�s�A:B7�7Cc���tj5ttj	��D]�\}}|j
t
j�k7s|j��4	t
j|j�}t|j|j
|j|j��t|<��	ddd�y#t$rY��wxYw#1swYyxYw)NrQ)r0r(r�r6rrr�rrrJrhrgrrKr)r�rWrNs   r4rYrY�s���	�	"�	"�!&�'9�'?�'?�'A�!B��E�:��%�%�����4�
�8I�8I�8U��
� �h�h�z�}�}�5��)9��=�=�&�2�2�"�)�)�!�(�(�	)��u�%�"C�
#�	"���
��
��

#�	"�s1�AC�$C
�AC�
	C�C�C�C�C%c��|�.	tj|�}|j|jf}t||�S#t$rY�wxYwr0)r�rJrKrrgrLrMs   r4rZrZ�sS����	>��(�(�2�,�K�#�)�)�;�+=�+=�=�H�#�B��1�1��	�	��	�s�=�	A	�A	c�"�|D]�}|j��	tj|j�}|j
|jf|j|jfk7r�btjt�5tj|j�ddd���|D]}|j��|D]}|j��tjj�y#t$rY��wxYw#1swY��xYwr0)rr�rJrhrgrKrrr�r&rfr5rEr�r�rd)r�r.r/rWrNrrs       r4rere�s���
"�
����$��	��(�(�:�=�=�1�K�
���� 2� 2�3�
�8I�8I�:�K[�K[�7\�\��
�
 �
 ��
)��H�H�Z�]�]�#�*�
)�"�#���+�+�-�#����#�#�%��
�N�N������	��	��*�
)�s�C5�> D�5	D�D�D	c���tj5ttj�}ddd�t	�vrytt
j
��}ttj
��}|D]Y}tjj|�x}s�%|gt|�z|dd|gt|�ztj|dd�[y#1swY��xYwr0)r0r'r�r-rr4r4r5r.r�r�r/)�fork_owner_thread_ids�objects�classesr\�object_snapshotss     r4rFrF�s���	�	�	� %�k�&C�&C� D��
��{�/�/���M�(�(�*�+�G��M�(�(�*�+�G�*�	�*�9�9�=�=�i�H�H��H�#*�)�c�2B�.C�"C��Q��8?�y�3�GW�CX�7X�K�&�&�y�1�!�4�+�

�	�s�C�C"c���|tvr;tjjstjr|�d�}t|��y|dk(r(tjjr
d}t|��yy)Nz: is unsafe while filelock is changing descriptor ownershipz_posixsubprocess.fork_execzCfork_exec is unsafe while filelock is changing descriptor ownership)r9r0r)r"r-r�)�event�_argsrs   r4r<r<�st��
�"�"��)�)�/�/�;�3P�3P��G�U�V�C��s�#�#�4Q�
�.�	.�;�3Q�3Q�3W�3W�S���3���4X�	.r6)rr�r�rjrhr_r�r\r�r�r�r/r�r�r�r�r�rQr`r�r�)r8ztype[BaseException])r~r�rr�r�r�r�r�rzztuple[str, _MarkerValue] | Noner8r)r�r�r8r9)r�r�r�r�r8ra)r�r�r�r
r8ra)r�r�r�r�r8r9)r�r�r�r�r8ra)r�r�r~r�rzztuple[str, _MarkerValue]r8z tuple[BaseException, ...] | Noner0)rr�r�r
r8r)r�r�r�r�r8r9)r�r�r�r�r8r)r~r�r�r�r�r
r8r)r�r"r8r�)r�type[BaseFileLock]r8r$)rgrfrrsr�r_r8rf)rFr�r8rh)rFr�r8rj)r�rar�rar�r�r8ra)rornr�rar�r�r8rnr7)rD�_ForkDescriptorOwner | Noner8r)rr.r8r9)rrCr8r9)rhr_r�r
r8r)rhr_r8r)rhr_r�r
r8r_)r�r_r8r9)rDrtr8r_)r�zlist[_OwnedDescriptor]r.ztuple[_ForkResettable, ...]r/z tuple[_ForkResettableClass, ...]r8r9)rqr�rrztuple[object, ...]r8r9)��
__future__rr�r(�loggingr;r�r�rur�r>�abcrr�collections.abcrrr�dataclassesr	�	itertoolsr
r�	threadingrr
rr�typingrrrrrrr�weakrefrr�_errorrr�_utilrrrqr rhr5r#rjr'r(�typesr)r*�_read_writer+�_soft_rwr,r.r>rCrGrvrR�typing_extensions�	getLoggerrTr�rVrWrXrYrZr]r_rar��_LockInitValuer\ryr�r|r�r�r�r�r�r�r�r�r�r��platformr��abspath�realpathr�r�r�r�r�r�r#rr$r�r�r�r�r��ContextDecoratorr�r�r_r^rr!r$r4r5r6r7r8r0r9r@r/r`rQr�r�rLr�r=r>r�r?rBrCrYrZrerFr<�__all__r1r6r4�<module>r�s���"�����	��
���'�.�%�!�$�8�8�T�T�T�:�8�"� "��*�!�%'��z�&��-�.��1:�G�W�;M�1N��.�N��9�:��/8�9Y�/Z��,�Z��)�#��*�+�:�(�:�_�x�_�
7�x�7��(�����7�"��*�!2��!2�!2�:�!>��	�>�37�8P�RY�Z\�^p�rv�Rw�3x��0�x�%6�d�%B��{�B��m�$���~�&���)�*�����t�#�c�)�D�0�8�S�E�4�K�3H�H��.�)�5�.�"
�$/3��
���� ��&�	�

,���
�N�,�0�"
� �&s��s�#&�s�0H�s�%�s��?�(�?��0P�$Z�	�
�	� �	�*�	��		�@C�|�|�w�?V�B�G�G�O�O�\^�\c�\c�\l�\l��)�l�A�,�5�,�*>�)?�	�&�?�
�T��(��@
�7�@
�F]n�\o��Y�o��,�$��1�1��1� �F
.�,���-��=A��MP��!��(J
"�:�.�.�,�J
"�^ � �*�("�("��("�VC�_�e�C��$�������U��0�0�:CV�BW�
�?�W�GZ�G\�
�D�\�9;��6�;�(-���%�/�(-���%�/��\��U�!�,5�y�,�6O�,P��)�P���*��*���6�2�	�,�
c�.&�(�
E� 
� &��"2��'��/��5��
�	�.
Y�	 ��	 �)�	 �	�	 ����r6