← back to Atmos Game

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

78 lines

�

c�bj�2���UddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
ddlmZddlmZmZdd	lmZmZmZdd
lmZddlmZmZmZmZdZd
ed<dZ ded<dZ!ded<dZ"ded<Gd�de�Z#dd�Z$dd�Z%dd�Z&dgZ'y)�)�annotationsN)�suppress)�EACCES�EEXIST�EPERM)�Path)�Final�)�BaseFileLock�_raise_grouped_errors)�	host_name�owner_is_stale�process_start_token)�STRICT_SOFT_SENTINEL_RECORD)�break_lock_file�ensure_directory_exists�raise_on_not_writable_file�	write_allg@zFinal[float]�_MALFORMED_LOCK_AGE_THRESHOLDiz
Final[int]�_MAX_LOCK_FILE_SIZE�
�_UNLINK_MAX_RETRIES��#_MARKER_WITH_START_TOKEN_LINE_COUNTc��eZdZUdZdZded<dZded<dZded	<dZded
<dd�Z	dd�Z
dd
�Zedd��Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zy)�SoftFileLockaz
    Cooperative file lock based on a shared existence marker.

    Unlike :class:`UnixFileLock <filelock.UnixFileLock>` and :class:`WindowsFileLock <filelock.WindowsFileLock>`, this
    lock does not use OS-level locking primitives. Instead, it creates the lock file with ``O_CREAT | O_EXCL`` and
    treats its existence as the lock indicator. The filesystem must provide coherent exclusive creation and directory
    updates to each participating process. A crash can leave the marker behind.

    The marker contains the holder's PID and hostname. A contender may remove it when it can no longer find a same-host
    process with that PID. A configured :attr:`~filelock.BaseFileLock.lifetime` also permits removal based on marker
    age, including while the holder remains alive. Age-based expiry can overlap protected operations and does not
    provide strict mutual exclusion.

    T�bool�_lifetime_supported)�StrictSoftFileLock�
SoftFileLeaseztuple[str, str] | None�_lifetime_replacementsF�_preserve_lock_file_supported�_on_acquired_supportedc�r�t|j�t|j�tjtj
ztjztjz}ttdd�x}�||z}	tj|j||j��}|j%|�|j'|�y#t$rT}|jtk(s'|jtk(rtj dk(s�|j#�Yd}~yd}~wwxYw)N�
O_NOFOLLOW�win32)r�	lock_filer�os�O_WRONLY�O_CREAT�O_EXCL�O_TRUNC�getattr�open�
_open_mode�OSError�errnorr�sys�platform�_try_break_stale_lock�_mark_descriptor_pending�_publish_held_marker)�self�flags�
o_nofollow�fd�	exceptions     �e/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/filelock/_soft.py�_acquirezSoftFileLock._acquire3s���"�4�>�>�2�����/����b�j�j�(�2�9�9�4�r�z�z�A��!�"�l�D�9�9�J�F��Z��E�	�����������0A�B�B�	
�%�%�b�)��!�!�"�%���	����6�)�i�o�o��.G�C�L�L�\c�Lc���&�&�(���
	�s�/C�	D6�"A
D1�1D6c���d}	ttj|��}|j|�|j||�y#t$r�|j�tj|�tt�5|�Nttj|j��|k(r#t|j�j�ddd��#1swY�xYwwxYw�N)�_file_identityr(�fstat�_write_lock_info�
BaseException�_mark_descriptor_released�closerr0�lstatr'r�unlink�_mark_descriptor_owned)r7r:�identitys   r<r6z!SoftFileLock._publish_held_markerGs���,0��		�%�b�h�h�r�l�3�H��!�!�"�%�	
�#�#�B��1���	��*�*�,��H�H�R�L��'�"��'�N�2�8�8�D�N�N�;S�,T�X`�,`�����(�/�/�1�#�
�#�
��
	�s$�/A�=C*�AC�	C*�C&	�"C*c��ttt�5t|j�\}}}|t
k(r
	ddd�yt
|�}|�?tj�|z
tk\rt|j||�	ddd�yt|�rt|j||�ddd�y#1swYyxYwr?)rr0�
ValueError�_read_lock_filer'r�_parse_lock_holder�timerrr)r7�content�mtime�ino�holders     r<r4z"SoftFileLock._try_break_stale_lockXs���
�g�z�
*�"1�$�.�.�"A��G�U�C��5�5��+�
*�(��0�F��~��9�9�;��&�*G�G�#�D�N�N�E�3�?��+�
*��v�&������s�;�+�
*�
*�s�$B6�AB6�B6�6B?c���tj��dt��d�}ttj��x}�||�d�z
}t	||j��y)N�
)r(�getpidr
rr�encode)r:�info�tokens   r<rBzSoftFileLock._write_lock_infojsT��
�)�)�+��b���
�R�0��(�����5�5�E�B��u�g�R�L� �D��"�d�k�k�m�$�c��ttt�5tt	|j
�d�}|�|dcddd�S	ddd�y#1swYyxYw)z�
        The PID of the process holding this lock, read from the lock file.

        :returns: the PID as an integer, or ``None`` if the lock file does not exist or cannot be parsed

        rN)rr0rKrMrLr')r7rRs  r<�pidzSoftFileLock.pidtsS���g�z�
*�'�����(G��(J�K�F��!��a�y�+�
*�!�+��	+��s�(A�Ac��ttt�5tt	|j
�d�}|�5|\}}}|t
j�k(xr
|t�k(cddd�S	ddd�y#1swYyxYw)z�
        Whether this lock is held by the current process.

        :returns: ``True`` if the lock file exists and names the current process's PID and hostname

        rNF)	rr0rKrMrLr'r(rUr
)r7rRr[�hostname�_s     r<�is_lock_held_by_uszSoftFileLock.is_lock_held_by_us�sr���g�z�
*�'�����(G��(J�K�F��!�#)� ��X�q��b�i�i�k�)�E�h�)�+�.E�	+�
*�!�+�
�+�
�s�AA8�8Bc��tt�5t|j�j	�ddd�y#1swYyxYw)zNForcibly break the lock by removing the lock file, regardless of who holds it.N)rr0rr'rG)r7s r<�
break_lockzSoftFileLock.break_lock�s+��
�g�
����� �'�'�)��
�
�s	�$=�Ac��|jj}|�J�d}tt�5t	tj|��}ddd�|j�	|j|d��|j|�y#1swY�?xYw#t$r;}	|j|��#t$r}td||�Yd}~�d}~wwxYwd}~wwxYw)NF)�default_suppressesz4lock descriptor close and marker cleanup both failed)�_context�lock_file_fdrr0r@r(rArD�_close_released_fdrC�_unlink_held_markerr)r7r:rI�close_error�
cleanup_errors     r<�_releasezSoftFileLock._release�s���
�]�]�
'�
'���~��~�,0��
�g�
�%�b�h�h�r�l�3�H��	
�&�&�(�	��#�#�B�5�#�A�	
� � ��*�%�
���		�
��(�(��2�
��
!�
�%�J��!���

��

��		�sG�B	�$B�	B�	C�B1�0C�1	C�:
C�C�C�C�Cc�8�|�ytjdk(r|j|�ytt�5tt
j|j��|k(r#t|j�j�ddd�y#1swYyxYw)Nr&)r2r3�_windows_unlink_if_oursrr0r@r(rFr'rrG)r7rIs  r<rgz SoftFileLock._unlink_held_marker�sh������<�<�7�"��(�(��2��'�"�!�"�(�(�4�>�>�":�;�x�G�����(�/�/�1�#�"�"�s�AB�Bc��d}tt�D]T}	ttj|j
��|k7ryt
|j
�j�yy#t$rN}|jtthvrYd}~y|tdz
krtj|�|dz}Yd}~��d}~wwxYw)Ng����MbP?r
�)�rangerr@r(rFr'rrGr0r1rrrN�sleep)r7rI�retry_delay�attempt�excs     r<rlz$SoftFileLock._windows_unlink_if_ours�s������0�1�G�
�!�"�(�(�4�>�>�":�;�x�G���T�^�^�$�+�+�-��2���
%��9�9�V�U�O�3���0�1�4�4��J�J�{�+��1�$�K���
%�s#�+A*�#A*�*	C�3B<�&B<�<CN)�return�None)r:�intrtru)rtz
int | None)rtr)rIztuple[int, int] | Nonertru)rI�tuple[int, int]rtru)�__name__�
__module__�__qualname__�__doc__r�__annotations__r!r"r#r=r6r4�staticmethodrB�propertyr[r_rarjrgrl�rYr<rrs���
� !%���$�6]��2�\�+0�!�4�/�$)��D�(�&�(2�"<�$�%��%���������*�
+�62�rYrc�2�|j|jfSr?)�st_dev�st_ino)�sts r<r@r@�s���9�9�b�i�i��rYc	�z�tj|�}tj|j�sd|j
|jfStj|tjttdd�zttdd�z�}	tj|�}tj|j�s.d|j
|jftj|�Stj|tdz�}tj|�t|�tkrAtt �5|j#d�|j
|jfcddd�Sd|j
|jfS#tj|�wxYw#1swY�<xYw)Nr%r�
O_NONBLOCKr
zutf-8)r(rF�stat�S_ISREG�st_mode�st_mtimer�r.�O_RDONLYr-rArE�readr�lenr�UnicodeDecodeError�decode)�pathr�r:�datas    r<rLrL�s2��

���$��B��<�<��
�
�#��R�[�[�"�)�)�+�+�
����r�{�{�W�R��q�%A�A�G�B�P\�^_�D`�`�	a�B��
�X�X�b�\���|�|�B�J�J�'�����b�i�i�/�	������w�w�r�.��2�3��
�����
�4�y�'�'�
�(�
)��;�;�w�'����b�i�i�?�*�
)�����b�i�i�'�'��		������
)�
)�s�AF�9F�(F1�F.�1F:c�
�|r+t|j�j�x}�dvry	t|d�}t|�tk(rt|d�nd}d|cxkrdksyy||d|fS#t
$rYywxYw)N>rnrrrnr
i���)r��strip�
splitlinesrvrrK)rO�linesr[�start_tokens    r<rMrM�s���
�c�7�=�=�?�#=�#=�#?�?�%�@��N����%��(�m��'*�5�z�5X�'X�c�%��(�m�^b��
�� �y� ��!����a��+�%�%������s�0A6�6	B�B)r�zos.stat_resultrtrw)r��strrtztuple[str | None, float, int])rOz
str | Nonertz"tuple[int, str, int | None] | None)(�
__future__rr(r�r2rN�
contextlibrr1rrr�pathlibr�typingr	�_apirr�	_identityr
rr�_soft_protocolr�_utilrrrrrr|rrrrr@rLrM�__all__rrYr<�<module>r�s���"�	��
���'�'���5�E�E�7�b�b�.1��|�1�"&��Z�&�"$��Z�$�23�#�Z�3�t�<�t�n �(�2&�,��rY