← back to Atmos Game

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

57 lines

�

c�bj�����UddlmZddlZddlZddlmZddlmZmZm	Z	ddl
mZmZddl
mZmZddlmZd	Zd
ed<dZd
ed<edZGd�de	�ZGd�de�Zdd�Zdd�Zdd�Zgd�Zy)�)�annotationsN)�suppress)�Final�Literal�
NamedTuple�)�	host_name�process_start_token)�SoftFileLock�_read_lock_file)�	write_allz
filelock/2z
Final[str]�	_PROTOCOLi���z
Final[int]�_MAX_PID)�lease�unknownc�Z�eZdZUdZded<ded<ded<dZd	ed
<dZded<dZd
ed<y)�OwnerRecordz+The owner published in a protocol 2 marker.�int�pid�str�hostname�	OwnerMode�modeN�
str | None�tokenzfloat | None�lease_duration�
int | None�start)�__name__�
__module__�__qualname__�__doc__�__annotations__rrr���g/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/filelock/_marker.pyrrs2��5�	�H��M�
�O��E�:��#'�N�L�'��E�:�r%rc�r�eZdZUdZded<edd��Zed
d��Zedd��Zdd�Z	dd�Z
dd	�Zdd
�Zy)�MarkerSoftFileLockzAAn existence lock whose marker carries a protocol 2 owner record.r�_owner_modec�"�|j�S)z�
        The owner named by the marker on disk.

        :returns: the published record, or ``None`` when no marker exists or its record is malformed or protocol 1

        )�_read_owner��selfs r&�ownerzMarkerSoftFileLock.owner)s�����!�!r%c�B�|j�x}�dS|jS)z�
        The PID of the process holding this lock, read from the marker.

        :returns: the PID, or ``None`` when no marker exists or its record is unreadable

        N)r+r�r-r.s  r&rzMarkerSoftFileLock.pid3s&��"&�!1�!1�!3�3��<�t�K�%�)�)�Kr%c��|j�}|duxr:|jtj�k(xr|jt�k(S)z�
        Whether the marker on disk names this process.

        :returns: ``True`` when the marker's PID and hostname match this process

        N)r+r�os�getpidrr	r0s  r&�is_lock_held_by_usz%MarkerSoftFileLock.is_lock_held_by_us=sC��� � �"���D� �_�U�Y�Y�"�)�)�+�%=�_�%�.�.�T]�T_�B_�_r%c�$�|j�y)a-
        Remove the marker whoever holds it, so a later contender can acquire.

        Forced breaking voids mutual exclusion: the previous holder keeps running and keeps using whatever the lock
        protects. Reserve it for an operator clearing a marker whose holder is known to be gone.
        N)�
break_lockr,s r&�force_breakzMarkerSoftFileLock.force_breakHs��	
���r%c��ttt�5tt	|j
�d�cddd�S#1swYyxYw)Nr)r�OSError�
ValueError�parse_markerr�	lock_filer,s r&r+zMarkerSoftFileLock._read_ownerQs1��
�g�z�
*������ ?�� B�C�+�
*�
*��s�!A�A	c�J�t|t|j���y)N)r
�
encode_marker�_published_record)r-�fds  r&�_write_lock_infoz#MarkerSoftFileLock._write_lock_infoVs���"�m�D�$:�$:�$<�=�>r%c	��ttj�t�|jttj����S)N)rrrr)rr2r3r	r)r
r,s r&r?z$MarkerSoftFileLock._published_recordYs4����	�	���[��!�!�%�b�i�i�k�2�	
�	
r%N)�return�OwnerRecord | None)rCr)rC�bool)rC�None)r@rrCrF)rCr)
rr r!r"r#�propertyr.rr4r7r+rAr?r$r%r&r(r(#s_��K���
�"��"��L��L��`��`���
?�
r%r(c��td|j��d|j��d|j��g}|j�|jd|j���|j�|jd|j���|j�|jd|j���djd�|D��j�S)	z>Render an owner record as the bytes a protocol 2 marker holds.zpid=zhost=zmode=ztoken=z	duration=zstart=�c3�&K�|]	}|�d����y�w)�
Nr$)�.0�lines  r&�	<genexpr>z encode_marker.<locals>.<genexpr>ks����1�5�4�d�V�2�;�5�s�)
rrrrr�appendrr�join�encode)�record�liness  r&r>r>bs���
�$�v�z�z�l�+�u�V�_�_�4E�-F�%�PV�P[�P[�}�H]�^�E�
�|�|��
���v�f�l�l�^�,�-�
���(�
���y��!6�!6� 9�:�;�
�|�|��
���v�f�l�l�^�,�-�
�7�7�1�5�1�1�8�8�:�:r%c���|r,|j�j�x}r|dtk7ryi}|ddD] }|jd�\}}}|sy|||<�"t	|�S)zcReturn the owner a protocol 2 marker names, or ``None`` when the record is malformed or protocol 1.rNr�=)�strip�
splitlinesr�	partition�
_build_record)�contentrS�fieldsrM�key�	separator�values       r&r;r;nss���G�M�M�O�$>�$>�$@�@�5�@�U�1�X�QZ�EZ���F��a�b�	�� $���s� 3���Y������s��	�
�� � r%c��|jd�x}�y|dk(rdnd}|jd�}|rd|vry	t|d�}d|vrt|d�nd}d|vrt|d�nd}d|cxkr	tksyy|jd	�}|dk(r|�|�tj|�r|d
kDsyt||||||��S#t$rYywxYw)Nrrr�hostr�durationrrrr)rrrrrr)�getr�floatr:r�math�isfiniter)r[�	publishedrrrrarrs        r&rYrY{s��
�Z�Z��'�'�	�0��!*�g�!5�g�9�D��z�z�&�!�H��u�F�*����&��-� ��0:�f�0D�5��
�+�,�$��(/�6�(9��F�7�O�$�t��
���x��� ���J�J�w��E��w��E�M�X�-=�d�m�m�T\�F]�bj�mn�bn���3���E�Zb�jo�p�p������s�6C�	C�C)r(rrr>r;)rRrrC�bytes)rZrrCrD)r[zdict[str, str]rCrD)�
__future__rrdr2�
contextlibr�typingrrr�	_identityr	r
�_softrr�_utilr
rr#rrrr(r>r;rY�__all__r$r%r&�<module>ross��"��	��-�-�5�0��
%�	�:�$� ��*� �
�&�'�	��*��<
��<
�~	;�
!�q�8�r%