ó
    -Vði9  ã                  ó    • S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	J
r
JrJr  S SKJr  SSKJr  SSKJrJr  S	rS
r " S S\5      rS/rg)é    )ÚannotationsN)Úsuppress)ÚEACCESÚEEXISTÚEPERMÚESRCH)ÚPathé   )ÚBaseFileLock)Úensure_directory_existsÚraise_on_not_writable_filei   éW   c                  óh   • \ rS rSrSrSS jrSS jr\SS j5       r\SS j5       r	SS jr
SS jrS	rg
)ÚSoftFileLocké   a�  
Portable file lock based on file existence.

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. This makes it work on any filesystem but leaves stale lock files behind
if the process crashes without releasing the lock.

To mitigate stale locks, the lock file contains the PID and hostname of the holding process. On contention, if the
holder is on the same host and its PID no longer exists, the stale lock is broken automatically.

c                óÜ  • [        U R                  5        [        U R                  5        [        R                  [        R
                  -  [        R                  -  [        R                  -  n[        [        SS 5      =nb  X-  n [        R                  " U R                  XR                  5       5      nU R                  U5        X0R                  l        g ! [         a‰  nUR                  [         :X  d)  UR                  ["        :X  a  [$        R&                  S:X  d  e UR                  [         :X  a.  [$        R&                  S:w  a  U R)                  5          S nAg  S nAg  S nAg S nAff = f)NÚ
O_NOFOLLOWÚwin32)r   Ú	lock_filer   ÚosÚO_WRONLYÚO_CREATÚO_EXCLÚO_TRUNCÚgetattrÚopenÚ
_open_modeÚ_write_lock_infoÚ_contextÚlock_file_fdÚOSErrorÚerrnor   r   ÚsysÚplatformÚ_try_break_stale_lock)ÚselfÚflagsÚ
o_nofollowÚfile_handlerÚ	exceptions        ÚSD:\a\ltx-desktop-ci\ltx-desktop-ci\python-embed\Lib\site-packages\filelock\_soft.pyÚ_acquireÚSoftFileLock._acquire    s  € Ü" 4§>¡>Ô2Ü §¡Ô/ä�K‰KÜ�j‰jñä�i‰iñô �j‰jñð 	ô "¤" l°DÓ9Ð9ˆJÑFØÑˆEð	6ÜŸ7š7 4§>¡>°5¿/¹/Ó:KÓLˆLð ×!Ñ! ,Ô/Ø)5�M‰MÕ&øô ó 	-à—‘¤6Ó)¨i¯o©oÄÓ.GÌCÏLÉLÐ\cÓLcàØ�‰¤&Ó(¬S¯\©\¸WÓ-DØ×*Ñ*×,Ñ,ô .EÔ(ûð	-ús   Â/C Ã
E+Ã"A5E&Å&E+c                ón  • [        [        5         [        U R                  5      R	                  SS9nUR                  5       R                  5       n[        U5      S:w  a
   S S S 5        g Uu  p4U[        R                  " 5       :w  a
   S S S 5        g [        U5      nU R                  U5      (       a
   S S S 5        g U R                   S[        R                  " 5        3n[        U R                  5      R                  U5        [        U5      R                  5         S S S 5        g ! , (       d  f       g = f)Nzutf-8)Úencodingé   z.break.)r   r!   r	   r   Ú	read_textÚstripÚ
splitlinesÚlenÚsocketÚgethostnameÚintÚ_is_process_aliver   ÚgetpidÚrenameÚunlink)r&   ÚcontentÚlinesÚpid_strÚhostnameÚpidÚ
break_paths          r+   r%   Ú"SoftFileLock._try_break_stale_lock8   sî   € Ü”gÕÜ˜4Ÿ>™>Ó*×4Ñ4¸gÐ4ÐFˆGØ—M‘M“O×.Ñ.Ó0ˆEÜ�5‹z˜Q‹Ø÷	 Ðð
 !&ÑˆGØœ6×-Ò-Ó/Ó/Ø÷ Ðô �g“,ˆCØ×%Ñ% c×*Ñ*Ø÷ Ðð !ŸN™NÐ+¨7´2·9²9³;°-Ð@ˆJÜ�—‘Ó ×'Ñ'¨
Ô3Ü�Ó×#Ñ#Ô%÷ ×Öús   �AD&Á*D&Â"D&Â<A!D&Ä&
D4c                ó¨  • [         R                  S:X  aa  SS KnUR                  R                  nUR                  [        SU 5      nU(       a  UR                  U5        gUR                  5       [        :g  $  [        R                  " U S5        g! [         a8  nUR                  [        :X  a   S nAgUR                  [        :X  a   S nAge S nAff = f)Nr   r   TF)r#   r$   ÚctypesÚwindllÚkernel32ÚOpenProcessÚ_WIN_SYNCHRONIZEÚCloseHandleÚGetLastErrorÚ_WIN_ERROR_INVALID_PARAMETERr   Úkillr!   r"   r   r   )r@   rD   rF   ÚhandleÚexcs        r+   r8   ÚSoftFileLock._is_process_aliveH   s¨   € ä�<‰<˜7Ó"Ûà—}‘}×-Ñ-ˆHØ×)Ñ)Ô*:¸A¸sÓCˆFÞØ×$Ñ$ VÔ,ØØ×(Ñ(Ó*Ô.JÑJÐJð	Ü�GŠG�C˜ŒOð øô ó 	Ø�y‰yœEÓ!ÜØ�y‰yœEÓ!ÜØûð	ús$   Á7B Â
CÂCÂ2CÃCÃCc                óø   • [        [        5         [        R                  " U [        R                  " 5        S[
        R                  " 5        S3R                  5       5        S S S 5        g ! , (       d  f       g = f)NÚ
)r   r!   r   Úwriter9   r5   r6   Úencode)Úfds    r+   r   ÚSoftFileLock._write_lock_info]   sJ   € ä”gÕÜ�HŠH�RœBŸIšI›K˜=¨¬6×+=Ò+=Ó+?Ð*@ÀÐC×JÑJÓLÔM÷ ×Öús   �AA+Á+
A9c                óŽ  • U R                   R                  c   e[        R                  " U R                   R                  5        S U R                   l        [        R
                  S:X  a  U R                  5         g [        [        5         [        U R                  5      R                  5         S S S 5        g ! , (       d  f       g = f)Nr   )r   r    r   Úcloser#   r$   Ú_windows_unlink_with_retryr   r!   r	   r   r;   )r&   s    r+   Ú_releaseÚSoftFileLock._releaseb   s{   € Ø�}‰}×)Ñ)Ñ5Ð5Ð5Ü
�Š�—‘×+Ñ+Ô,Ø%)ˆ�‰Ô"Ü�<‰<˜7Ó"Ø×+Ñ+Õ-äœ'Õ"Ü�T—^‘^Ó$×+Ñ+Ô-÷ #×"Ö"ús   Â	$B6Â6
Cc                ó:  • SnSn[        U5       H'  n [        U R                  5      R                  5           g    g ! [         aT  nUR
                  [        [        1;  a   S nA  g X1S-
  :  a!  [        R                  " U5        US-  n S nAM   S nAM…  S nAff = f)Né
   gü©ñÒMbP?r
   r0   )
Úranger	   r   r;   r!   r"   r   r   ÚtimeÚsleep)r&   Úmax_retriesÚretry_delayÚattemptrN   s        r+   rX   Ú'SoftFileLock._windows_unlink_with_retryl   s„   € ØˆØˆÜ˜[Ö)ˆGð	Ü�T—^‘^Ó$×+Ñ+Ô-ñ ò *øô ó %Ø—9‘9¤V¬U OÓ3ÝØ¨1™_Ó,Ü—J’J˜{Ô+Ø 1Ñ$–Kõ -ûð%ús   ”#<¼
BÁBÁ&#BÂB© N)ÚreturnÚNone)r@   r7   re   Úbool)rT   r7   re   rf   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r,   r%   Ústaticmethodr8   r   rY   rX   Ú__static_attributes__rd   ó    r+   r   r      sE   † ñô6ô0&ð  óó ðð( óNó ðNô.÷ro   r   )Ú
__future__r   r   r5   r#   r^   Ú
contextlibr   r"   r   r   r   r   Úpathlibr	   Ú_apir   Ú_utilr   r   rH   rK   r   Ú__all__rd   ro   r+   Ú<module>rv      sM   ðÝ "ã 	Û Û 
Û Ý ß .Ó .Ý å ß FàÐ Ø!Ð ôh�<ô hðX ð�ro   