+
    &j!                        ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
HtHt ^ RIHt ^RIHt ^RIHtHt Rt^WtR	tR
tRt ! R R]4      tR R ltR.tR# )    )annotationsN)suppress)EACCESEEXISTEPERMESRCH)Path)BaseFileLock)ensure_directory_existsraise_on_not_writable_filei   i   g       @i   c                      ] tR t^tRtR R ltR R ltR R lt]R R	 l4       t	]R
 R l4       t
]R R l4       t]R R l4       t]R R l4       tR R ltR R ltR R ltRtR# )SoftFileLocka  
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                   V ^8  d   QhRR/#    returnNone )formats   "f/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/filelock/_soft.py__annotate__SoftFileLock.__annotate__#   s     6 6$ 6    c                	   \        V P                  4       \        V P                  4       \        P                  \        P
                  ,          \        P                  ,          \        P                  ,          p\        \        R R4      ;pe	   W,          p \        P                  ! V P                  WP                  4       4      pV P                  V4       W0P                  n        R#   \         d\   pTP                  \         8X  g,   TP                  \"        8X  d   \$        P&                  R8X  g   h T P)                  4         Rp?R# Rp?ii ; i)
O_NOFOLLOWN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   &    r   _acquireSoftFileLock._acquire#   s    "4>>2/KKjjii jj 	 ""lD99JFE
	6774>>5//:KLL !!,/)5MM&  	)6)ioo.GCLL\cLc&&((	)s   /C* *E5AEEc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   :   s     $ $t $r   c                	H   \        \        \        4      ;_uu_ 4        \        V P                  4      w  rV'       d   VP                  4       P                  4       M. p\        V4      R9  dA   \        P                  ! 4       V,
          \        8  d   V P                  4         RRR4       R# V^ ,          V^,          rT\        V4      ^8X  d
   V^,          MRpV\        P                  ! 4       8w  d    RRR4       R# \        V4      pV P                  V4      '       dW   \        P                   R8X  d7   Ve3   \        V4      pV P#                  V4      p	V	e   W8w  d   M RRR4       R#  RRR4       R# V P                  4        RRR4       R#   + '       g   i     R# ; i)r   Nr   >   r      )r   r)   
ValueError_read_lock_filer   strip
splitlineslentime_MALFORMED_LOCK_AGE_THRESHOLD_evict_lock_filesocketgethostnameint_is_process_aliver+   r,   _get_process_creation_time)
r.   contentmtimelinespid_strhostnamecreation_time_strpidstoredactuals
   &         r   r-   "SoftFileLock._try_break_stale_lock:   s=   gz**,T^^<NG4;GMMO..0E5z'99;&*GG))+ +* !&a%(X,/J!Oa6--// +* g,C%%c**<<7*/@/L !23F!<<SAF)f.>1 +*4 5 +*8 !!#9 +***s&   BF-AF>A#F+F6FF!	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   Y   s     " "$ "r   c                	    V P                    R \        P                  ! 4        2p\        V P                   4      P	                  V4       \        V4      P                  4        R# )z.break.N)r   r   getpidr	   renameunlink)r.   
break_paths   & r   r?   SoftFileLock._evict_lock_fileY   sE    'wryy{m<
T^^##J/Z!r   c                    V ^8  d   QhRRRR/# )r   rK   rB   r   boolr   )r   s   "r   r   r   _   s      s t r   c                	   \         P                  R 8X  dd   ^ RIpVP                  P                  pVP                  \        ^ V 4      pV'       d   VP                  V4       R# VP                  4       \        8g  #  \        P                  ! V ^ 4       R#   \         d=   pTP                  \        8X  d    Rp?R# TP                  \        8X  d    Rp?R# h Rp?ii ; i)r   NTF)r+   r,   ctypeswindllkernel32OpenProcess_WIN_SYNCHRONIZECloseHandleGetLastError_WIN_ERROR_INVALID_PARAMETERr   killr)   r*   r   r   )rK   rY   r[   handleexcs   &    r   rC   SoftFileLock._is_process_alive^   s    <<7"}}--H))*:AsCF$$V,((*.JJJ	GGCO   	yyE!yyE!	s$   :B CC9CCCc                    V ^8  d   QhRRRR/# )r   rK   rB   r   
int | Noner   )r   s   "r   r   r   t   s     H H H
 Hr   c           	        \         P                  R8w  d   R# ^ RIp^ RIHp VP                  P
                  pVP                  \        ^ V 4      pV'       g   R#  VP                  4       pVP                  4       pVP                  4       pVP                  4       pVP                  VVP                  V4      VP                  V4      VP                  V4      VP                  V4      4      '       g    VP                  V4       R#  VP                  V4       VP                  ^ ,          VP                  ,          #   TP                  T4       i ; i)zRReturn the process creation FILETIME as an integer on Windows, ``None`` otherwise.r   N)wintypes)r+   r,   rY   rh   rZ   r[   r\   &_WIN_PROCESS_QUERY_LIMITED_INFORMATIONFILETIMEGetProcessTimesbyrefr^   dwHighDateTimedwLowDateTime)	rK   rY   rh   r[   rb   creation	exit_timekernel_time	user_times	   &        r   rD   'SoftFileLock._get_process_creation_times   s    <<7"#==))%%&LaQTU	)((*H ))+I"++-K ))+I++X&Y'[)Y'    (   (''2-1G1GGG   (s   BD; ;Ec                    V ^8  d   QhRRRR/# )r   fdrB   r   r   r   )r   s   "r   r   r      s     ( (S (T (r   c                	   \        \        4      ;_uu_ 4        \        P                  ! 4        R \        P
                  ! 4        R 2p\        P                  R8X  d8   \        P                  \        P                  ! 4       4      ;pe   W R 2,          p\        P                  ! WP                  4       4       RRR4       R#   + '       g   i     R# ; i)
r   N)r   r)   r   rQ   r@   rA   r+   r,   r   rD   writeencode)ru   infocts   &  r   r&   SoftFileLock._write_lock_info   s    giik]"V%7%7%9$:"=D||w&,2Y2YZ\ZcZcZe2f,fB+s$b	!HHR'	 s   BCC	c                   V ^8  d   QhRR/# )r   r   rf   r   )r   s   "r   r   r      s      Z r   c                :   \        \        \        4      ;_uu_ 4        \        V P                  4      w  rV'       dC   VP                  4       P                  4       ;p'       d   \        V^ ,          4      uuRRR4       # RRR4       R#   + '       g   i     R# ; i)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

N)r   r)   r8   r9   r   r:   r;   rB   )r.   rE   _rG   s   &   r   rK   SoftFileLock.pid   sf     gz**(8JGW]]_%?%?%AAEA58} +** 	 +* s   AB	#B		B	c                   V ^8  d   QhRR/# )r   r   rW   r   )r   s   "r   r   r      s     ' 'D 'r   c                F    V P                   \        P                  ! 4       8H  # )z
Whether this lock is held by the current process.

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

)rK   r   rQ   r.   s   &r   is_lock_held_by_usSoftFileLock.is_lock_held_by_us   s     xx299;&&r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     * *D *r   c                    \        \        4      ;_uu_ 4        \        V P                  4      P	                  4        RRR4       R#   + '       g   i     R# ; i)zNForcibly break the lock by removing the lock file, regardless of who holds it.N)r   r)   r	   r   rS   r   s   &r   
break_lockSoftFileLock.break_lock   s1    g '') s   $AA	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     . .$ .r   c                	   V P                   P                  f   Q h\        P                  ! V P                   P                  4       R V P                   n        \        P
                  R8X  d   V P                  4        R # \        \        4      ;_uu_ 4        \        V P                  4      P                  4        R R R 4       R #   + '       g   i     R # ; i)Nr   )r'   r(   r   closer+   r,   _windows_unlink_with_retryr   r)   r	   r   rS   r   s   &r   _releaseSoftFileLock._release   s    }}))555
++,%)"<<7"++-'""T^^$++- #"""s   $CC	c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s      D r   c                	V   ^
pRp\        V4       F(  p \        V P                  4      P                  4         R# 	  R#   \         d`   pTP
                  \        \        09  d    Rp? R# Y1^,
          8  d&   \        P                  ! T4       T^,          p Rp?K   Rp?K  Rp?ii ; i)
   gMbP?N)
ranger	   r   rS   r)   r*   r   r   r=   sleep)r.   max_retriesretry_delayattemptrc   s   &    r   r   'SoftFileLock._windows_unlink_with_retry   s    [)G	T^^$++-  *  %99VUO31_,JJ{+1$K -%s   #>B(	B#+,B##B(r   N)__name__
__module____qualname____firstlineno____doc__r3   r-   r?   staticmethodrC   rD   r&   propertyrK   r   r   r   r   __static_attributes__r   r   r   r   r      s    6.$>"
  ( H H8 ( (   ' '*
. r   r   c                    V ^8  d   QhRRRR/# )r   pathstrr   ztuple[str | None, float]r   )r   s   "r   r   r      s      # ": r   c           	     P   \         P                  ! V \         P                  \        \         R ^ 4      ,          \        \         R^ 4      ,          4      p \         P                  ! V4      P
                  \         P                  ! V\        ^,           4      r2\         P                  ! V4       \        V4      \        8:  d6   \        \        4      ;_uu_ 4        VP                  R4      V3uuRRR4       # RV3#   \         P                  ! T4       i ; i  + '       g   i     RT3# ; i)r   
O_NONBLOCKzutf-8N)r   r$   O_RDONLYr#   fstatst_mtimeread_MAX_LOCK_FILE_SIZEr   r<   r   UnicodeDecodeErrordecode)r   ru   rF   datas   &   r   r9   r9      s     
r{{WRq%AAGBP\^_D``	aBhhrl++RWWR9Lq9P-Qt

4y''());;w'. *);	 	));s   AC7 D7DD%	)
__future__r   r   r@   r+   r=   
contextlibr   r*   r   r   r   r   pathlibr	   _apir
   _utilr   r   r]   r`   ri   r>   r   r   r9   __all__r   r   r   <module>r      sd    " 	  
   . .   F ! )/ & #  x< xv$ r   