+
    2j                      a  0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IH t  ^ RI!H"t" ]'       d	   ^ RI#H$t$H%t% ]R=,          t&Rt'Rt(])! ]R^ 4      t*])! ]R^ 4      t+]PX                  R8g  ;'       d    ]PZ                  ]P\                  9   t/]! 4       t0R]1R&   ]Pd                  ! 4       s3Rs4Rs5]! RR7       ! R R4      4       t6] ! R R4      4       t7]! RR7       ! R R4      4       t8] ! R R4      4       t9 ! R R ]:4      t; ! R! R"];R#7      t< ! R$ R%]Pz                  4      t>R&R/R' R( llt?R&R/R) R* llt@R+ R, ltAR&R/R- R. lltBR&R/R/ R0 lltCR&R/R1 R2 lltDR3 R4 ltER5 R6 ltFR7 R8 ltGR9 R: ltHR; R< ltIR".tJR# )>zZCross-process and cross-host reader/writer lock built on :class:`SoftFileLock` primitives.)annotationsN)contextmanagersuppress)	dataclass)Path)TYPE_CHECKINGLiteral)WeakValueDictionary)AcquireReturnProxy)Timeout)SoftFileLock)ensure_directory_exists)Callable	Generatorz.breaki   
O_NOFOLLOW
O_NONBLOCKwin32,WeakValueDictionary[Path, SoftReadWriteLock]_all_instancesFT)frozenc                  6    ] tR t^.t$ R]R&   R]R&   R]R&   RtR# )_Pathsstrstatewritereaders N__name__
__module____qualname____firstlineno____annotations____static_attributes__r       7lib/python3.14/site-packages/filelock/_soft_rw/_sync.pyr   r   .   s    JJLr$   r   c                  6    ] tR t^5t$ R]R&   R]R&   R]R&   RtR# )_Locksthreading.Lockinternaltransactionr   r   r   Nr   r   r$   r%   r'   r'   5   s    r$   r'   c                  6    ] tR t^<t$ R]R&   R]R&   R]R&   RtR# )_MarkerInfor   tokenintpidhostnamer   Nr   r   r$   r%   r,   r,   <   s    J	HMr$   r,   c                  l    ] tR t^Ct$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   R]R&   R]R&   R]R&   RtR# )_HoldzYEverything that exists only while a lock is held; ``None`` when the instance has no lock.r.   level_Modemode
int | Nonewrite_thread_idr   marker_namebool	is_readerr-   _HeartbeatThreadheartbeat_threadthreading.Eventheartbeat_stopr   N)r   r   r    r!   __doc__r"   r#   r   r$   r%   r2   r2   C   s1    cJ
KOJ&&##r$   r2   c                  `   a  ] tR t^Qt$ R]R&   R]R&   RRRRRRR	R
RRR/R V 3R lllltRtV ;t# )_SoftRWMetar   
_instancesr(   _instances_lockblockingTis_singletonheartbeat_interval      >@stale_thresholdNpoll_interval      ?c               8    V ^8  d   QhRRRRRRRRRRR	R
RRRR/# )   	lock_filestr | os.PathLike[str]timeoutfloatrD   r9   rE   rF   rH   float | NonerI   returnSoftReadWriteLockr   )formats   "r%   __annotate___SoftRWMeta.__annotate__U   sZ     * *)* *
 * * "* &* * 
*r$   c               	  < V'       g   \         SV `  VVVVVVVR 7      # \        V4      P                  4       pV P                  ;_uu_ 4        V P
                  P                  V4      p	V	f&   \         SV `  VVVVVVVR 7      p	WP
                  V&   MOV	P                  V8w  g   V	P                  V8w  d.   RV	P                   RV	P                   RV RV 2p
\        V
4      hV	uuRRR4       #   + '       g   i     R# ; i))rD   rE   rF   rH   rI   Nz$Singleton lock created with timeout=z, blocking=z, cannot be changed to timeout=)
super__call__r   resolverC   rB   getrO   rD   
ValueError)clsrM   rO   rD   rE   rF   rH   rI   
normalizedinstancemsg	__class__s   &&&$$$$$   r%   rY   _SoftRWMeta.__call__U   s    7#!)#5 /+ $   )_,,.
   ~~))*5H 7+%!-'9$3"/ ,  .6z*!!W,0A0AX0M:8;K;K:LKX`XiXiWj k55<I[
T  !o%' !   s   BC--C>	r   )r   r   r    r!   r"   rY   r#   __classcell__ra   s   @r%   rA   rA   Q   sP    <<##*
 * "* %)* )-*  $* * *r$   rA   c                     ] tR t^t$ Rt]! 4       tR]R&   ]P                  ! 4       t
R8RRRRRRR	R
RR/R R lllt]R9RR
/R R lll4       t]R9RR
/R R lll4       tR9RR
/R R llltR9RR
/R R llltR R ltRR/R R llt]R8RR/R R lll4       tR R  ltR! R" ltR# R$ ltR% R& ltR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltR5 R6 lt R7t!R
# ):rS   uE
  
Cross-process and cross-host reader/writer lock built on :class:`SoftFileLock` primitives.

Use this class instead of :class:`~filelock.ReadWriteLock` when the lock file lives on a network
filesystem (NFS, Lustre with ``-o flock``, HPC cluster shared storage). ``ReadWriteLock`` is backed
by SQLite and cannot run on NFS because SQLite's ``fcntl`` locking is unreliable there.

Layout on disk for a lock at ``foo.lock``:

- ``foo.lock.state`` — a :class:`SoftFileLock` taken only during state transitions (microseconds).
- ``foo.lock.write`` — writer marker; its presence means a writer is claiming or holding the lock.
- ``foo.lock.readers/<host>.<pid>.<uuid>`` — one file per reader.

Each marker stores a random token (``secrets.token_hex(16)``), the holder's pid, and the holder's
hostname. A daemon heartbeat thread refreshes ``mtime`` on every held marker. A marker whose mtime
has not advanced in ``stale_threshold`` seconds may be evicted by any process on any host, giving
correct behavior when a compute node crashes with a lock held.

Writer acquire is two-phase and writer-preferring: phase 1 claims ``.write`` (blocking any new
reader), phase 2 waits for existing readers to drain. Writer starvation is impossible.

Reentrancy, upgrade/downgrade rules, thread pinning, and singleton caching by resolved path match
:class:`~filelock.ReadWriteLock`.

Forking while holding a lock invalidates the inherited instance in the child so the child cannot
double-own the lock with its parent; ``release()`` on a fork-invalidated instance is a no-op, and
the child must re-acquire if it needs a lock.

Trust boundary: protects against same-UID non-cooperating processes (one host or cross-host) and
same-host different-UID users via ``0o600`` / ``0o700`` permissions. Does not protect against root
compromise, NTP tampering on same-UID cross-host nodes, or multi-tenant mounts where hostile
co-tenants share the UID.

:param lock_file: path to the lock file; sidecar state/write/readers live next to it
:param timeout: maximum wait time in seconds; ``-1`` means block indefinitely
:param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately on contention
:param is_singleton: if ``True``, reuse existing instances for the same resolved path
:param heartbeat_interval: seconds between heartbeat refreshes; default 30 s
:param stale_threshold: seconds of ``mtime`` inactivity before a marker is stale; defaults to
    ``3 * heartbeat_interval``, matching etcd's ``LeaseKeepAlive`` convention
:param poll_interval: seconds between acquire retries under contention; default 0.25 s

.. versionadded:: 3.27.0

r   rB   rD   TrE   rF   rG   rH   NrI   rJ   c               8    V ^8  d   QhRRRRRRRRRRR	R
RRRR/# )rL   rM   rN   rO   rP   rD   r9   rE   rF   rH   rQ   rI   rR   Noner   )rT   s   "r%   rU   SoftReadWriteLock.__annotate__   sZ     0 0)0 0
 0 0 "0 &0 0 
0r$   c          	     	f   V^ 8:  d   RV 2p\        V4      hVf
   V^,          pWe8:  d   RV RV R2p\        V4      hV^ 8:  d   RV 2p\        V4      h\        P                  ! V4      V n        W n        W0n        WPn        W`n        Wpn        \        V P                   R2V P                   R2V P                   R	2R
7      V n
        \        V P                  4       \        \        P                  ! 4       \        P                  ! 4       \        V P                  P                   RR7      R7      V n        RV n        RV n        RV n        RV n        \,        ;_uu_ 4        V \.        \1        V P                  4      P3                  4       &   \5        4        RRR4       R#   + '       g   i     R# ; i)    z)heartbeat_interval must be positive, got Nz0stale_threshold must exceed heartbeat_interval (z <= )z$poll_interval must be positive, got z.statez.writez.readers)r   r   r   rO   r)   r*   r   Frd   )r\   osfspathrM   rO   rD   rF   rH   rI   r   _pathsr   r'   	threadingLockr   r   _locks_readers_dir_fd_hold_fork_invalidated_closed_all_instances_lockr   r   rZ   _register_hooks)	selfrM   rO   rD   rE   rF   rH   rI   r`   s	   &&&$$$$$ r%   __init__SoftReadWriteLock.__init__   sy    "=>P=QRCS/!"014O0D_DUUYZlYmmnoCS/!A8HCS/! ii	2%&);&5$1^^$F+^^$F+~~&h/

 	 /^^%!(t{{00"=

 ,0#'
',"  =AN4/779: !   s    5FF0	c               $    V ^8  d   QhRRRRRR/# rL   rO   rQ   rD   bool | NonerR   zGenerator[None]r   )rT   s   "r%   rU   rj      s"       ; Zi r$   c             #     "   V P                  WR7        Rx  V P                  4        R#   T P                  4        i ; i5i)a  
Context manager that acquires and releases a shared read lock.

Falls back to instance defaults for *timeout* and *blocking* when ``None``.

:param timeout: maximum wait time in seconds, or ``None`` to use the instance default
:param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately; ``None`` uses the instance default

:raises RuntimeError: if a write lock is already held on this instance
:raises Timeout: if the lock cannot be acquired within *timeout* seconds

rD   N)acquire_readreleaser|   rO   rD   s   &&$r%   	read_lockSoftReadWriteLock.read_lock   s2      	'5	LLNDLLN   A, A>Ac               $    V ^8  d   QhRRRRRR/# r   r   )rT   s   "r%   rU   rj      s"      , K [j r$   c             #     "   V P                  WR7        Rx  V P                  4        R#   T P                  4        i ; i5i)a  
Context manager that acquires and releases an exclusive write lock.

Falls back to instance defaults for *timeout* and *blocking* when ``None``.

:param timeout: maximum wait time in seconds, or ``None`` to use the instance default
:param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately; ``None`` uses the instance default

:raises RuntimeError: if a read lock is already held, or a write lock is held by a different thread
:raises Timeout: if the lock cannot be acquired within *timeout* seconds

r   N)acquire_writer   r   s   &&$r%   
write_lockSoftReadWriteLock.write_lock   s2      	76	LLNDLLNr   c               $    V ^8  d   QhRRRRRR/# rL   rO   rQ   rD   r   rR   r
   r   )rT   s   "r%   rU   rj     s'     A AL Ak A]o Ar$   c               (    V P                  RWR7      # )u  
Acquire a shared read lock.

If this instance already holds a read lock, the lock level is incremented (reentrant). Attempting to acquire a
read lock while holding a write lock raises :class:`RuntimeError` (downgrade not allowed). On the 0→1
transition a daemon heartbeat thread is started that refreshes the reader marker's ``mtime`` every
``heartbeat_interval`` seconds so peers on other hosts do not evict the marker as stale.

:param timeout: maximum wait time in seconds, or ``None`` to use the instance default; ``-1`` means block
    indefinitely
:param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately when the lock is unavailable;
    ``None`` uses the instance default

:returns: a proxy that can be used as a context manager to release the lock

:raises RuntimeError: if a write lock is already held on this instance, if this instance was invalidated by
    :func:`os.fork`, or if :meth:`close` was called
:raises Timeout: if the lock cannot be acquired within *timeout* seconds

readr   _acquirer   s   &&$r%   r   SoftReadWriteLock.acquire_read  s    * }}VW}@@r$   c               $    V ^8  d   QhRRRRRR/# r   r   )rT   s   "r%   rU   rj   %  s'     B B\ B{ B^p Br$   c               (    V P                  RWR7      # )a   
Acquire an exclusive write lock.

If this instance already holds a write lock from the same thread, the lock level is incremented (reentrant).
Attempting to acquire a write lock while holding a read lock raises :class:`RuntimeError` (upgrade not
allowed). Write locks are pinned to the acquiring thread: a different thread trying to re-enter also raises
:class:`RuntimeError`.

Writer acquisition runs in two phases. Phase 1 atomically claims ``<path>.write`` via ``O_CREAT | O_EXCL``,
which immediately blocks any new reader on any host. Phase 2 waits for existing readers to drain. Writer
starvation is impossible: new readers see ``<path>.write`` during phase 2 and wait behind the pending writer.

:param timeout: maximum wait time in seconds, or ``None`` to use the instance default; ``-1`` means block
    indefinitely
:param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately when the lock is unavailable;
    ``None`` uses the instance default

:returns: a proxy that can be used as a context manager to release the lock

:raises RuntimeError: if a read lock is already held, if a write lock is held by a different thread, if this
    instance was invalidated by :func:`os.fork`, or if :meth:`close` was called
:raises Timeout: if the lock cannot be acquired within *timeout* seconds

r   r   r   r   s   &&$r%   r   SoftReadWriteLock.acquire_write%  s    2 }}Wg}AAr$   c                   V ^8  d   QhRR/# rL   rR   ri   r   )rT   s   "r%   rU   rj   @  s     , ,t ,r$   c           	        V P                  RR7       V P                  P                  ;_uu_ 4        V P                  '       d    RRR4       R# RV n        V P                  eH   \        \        4      ;_uu_ 4        \        P                  ! V P                  4       RRR4       RV n        RRR4       R#   + '       g   i     L!; i  + '       g   i     R# ; i)u   
Release any held lock and release internal filesystem resources.

Idempotent. After calling this method the instance can no longer acquire locks — subsequent acquires raise
:class:`RuntimeError`. A fork-invalidated instance is closed without raising.
TforceN)	r   ru   r)   ry   rv   r   OSErrorrp   closer|   s   &r%   r   SoftReadWriteLock.close@  s     	4 [[!!!||| "!  DL##/g&&HHT112 ''+$ "!
 '& "!!s)   C,C;!B5	C5C CC	r   Fc                    V ^8  d   QhRRRR/# )rL   r   r9   rR   ri   r   )rT   s   "r%   rU   rj   Q  s     (& (& (& (&r$   c                  V P                   P                  ;_uu_ 4        V P                  '       d   RV n         RRR4       R# V P                  pVf;   V'       d    RRR4       R# RV P                   R\        V 4       R2p\        V4      hV'       d	   ^ Vn        MV;P                  ^,          un        VP                  ^ 8  d    RRR4       R# RV n        RRR4       XP                  P                  4        VP                  P                  V P                  R,           R7       VP                  '       d$   \        VP                  V P                   R7       R# \        VP                  4       R#   + '       g   i     L; i)a   
Release one level of the current lock.

When the lock level reaches zero the heartbeat thread is stopped and the held marker file is unlinked. On a
fork-invalidated instance (that is, the child of a :func:`os.fork` call made while the parent held a lock)
this method is a no-op so inherited ``with`` blocks can unwind cleanly in the child.

:param force: if ``True``, release the lock completely regardless of the current lock level

:raises RuntimeError: if no lock is currently held and *force* is ``False``

NzCannot release a lock on  (lock id: z) that is not heldg      ?rn   dir_fd)ru   r)   rx   rw   rM   idRuntimeErrorr3   r>   setr<   joinrF   r:   _unlinkr8   rv   )r|   r   holdr`   s   &$  r%   r   SoftReadWriteLock.releaseQ  s#    [[!!!%%%!
	 "!
 ::D| "! 2$..1ARPTXJVhi"3''


a
zzA~! "!" DJ# ", 	!""4+B+BS+H"I>>>D$$T-A-ABD$$%7 "!s)   E5E5E5'.E53E5E55F	c               (    V ^8  d   QhRRRRRRRR/# )	rL   rM   rN   rO   rP   rD   r9   rR   rS   r   )rT   s   "r%   rU   rj   |  s2     : :): :
 : 
:r$   c                   V ! WVR7      # )a  
Return the singleton :class:`SoftReadWriteLock` for *lock_file*.

:param lock_file: path to the lock file; sidecar state/write/readers live next to it
:param timeout: maximum wait time in seconds; ``-1`` means block indefinitely
:param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately when the lock is unavailable

:returns: the singleton lock instance

:raises ValueError: if an instance already exists for this path with different *timeout* or *blocking* values

r   r   )r]   rM   rO   rD   s   &&&$r%   get_lockSoftReadWriteLock.get_lock{  s    ( 999r$   c               (    V ^8  d   QhRRRRRRRR/# )	rL   r5   r4   rO   rQ   rD   r   rR   r
   r   )rT   s   "r%   rU   rj     s2      .  . .  .
  . 
 .r$   c               	   Vf   V P                   MTpVf   V P                  MTpV P                  P                  ;_uu_ 4        V P                  '       d   RV P
                   R2p\        V4      hV P                  '       d   RV P
                   R2p\        V4      hV P                  e   V P                  V4      uuR R R 4       #  R R R 4       \        P                  ! 4       pV'       g(   V P                  P                  P                  RR7      pMUVR8X  d(   V P                  P                  P                  RR7      pM'V P                  P                  P                  RVR7      pV'       g   \        V P
                  4      R h V P                  WWSR7      V P                  P                  P!                  4        #   + '       g   i     L; i  T P                  P                  P!                  4        i ; i)	NzSoftReadWriteLock on z4 was invalidated by fork(); construct a new instancez has been closedFr   T)rD   rO   rd   )rO   rD   ru   r)   rx   rM   r   ry   rw   _validate_reentranttimeperf_counterr*   acquirer   _do_acquire_innerr   )r|   r5   rO   rD   r`   startacquireds   &&&$   r%   r   SoftReadWriteLock._acquire  s    #*/$,,w$,$44==([[!!!%%%-dnn-==qr"3''|||-dnn-==MN"3''zz%//5 "! & " !!#{{..666FH]{{..666EH{{..66g6VH$..)t3	.))$)RKK##++-- "!, KK##++-s   ?F?9F?G ?G	&G8c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
rL   r5   r4   effective_timeoutrP   r   rD   r9   rR   r
   r   )rT   s   "r%   rU   rj     s<     $- $-$- !$- 	$- $- 
$-r$   c               	   V P                   P                  ;_uu_ 4        V P                  e   V P                  V4      uuR R R 4       #  R R R 4       VR8X  d   R MW2,           p\        P
                  ! ^4      pVR8X  d   V P                  WeVR7      w  rxMV P                  WeVR7      w  rx\        P                  ! 4       p	\        V P                  V P                  V	R\        V 4      R 2R7      p
V P                   P                  ;_uu_ 4        \        ^TVR8X  d   \        P                  ! 4       MR VVVV
V	R7      V n        R R R 4       V
P!                  4        \#        V R7      #   + '       g   i     EL&; i  + '       g   i     L@; i)	Nr   deadlinerD   zfilelock-heartbeat-x)refreshinterval
stop_eventname)r3   r5   r7   r8   r:   r-   r<   r>   lockrd   )ru   r)   rw   r   secrets	token_hex_acquire_writer_slot_acquire_reader_slotrs   Eventr;   _refresh_markerrF   r   r2   	get_identr   r
   )r|   r5   r   r   rD   r   r-   r8   r:   r   	heartbeats   &&&&$      r%   r   #SoftReadWriteLock._do_acquire_inner  sM    [[!!!zz%//5 "!% " -248Q!!"%7?%)%>%>ubj%>%k"K%)%>%>ubj%>%k"K__&
$((,,!&r$xl3	
	 [[!!!9=	 3 3 5d'#!*)	DJ " 	!t,,9 "!!  "!s   E'5E;'E8	;F	c                    V ^8  d   QhRRRR/# )rL   r5   r4   rR   r
   r   )rT   s   "r%   rU   rj     s     - - -2D -r$   c                	   V P                   pVf   Q hVP                  V8w  dG   VR8X  d   RMRpVR8X  d   RMRpRV RV P                   R\        V 4       RV R	V R
2p\	        V4      hVR8X  d\   \
        P                  ! 4       ;qbP                  8w  d7   RV P                   R\        V 4       RV RVP                   2p\	        V4      hV;P                  ^,          un        \        V R7      # )Nr   r   	downgradeupgradezCannot acquire z	 lock on r   z): already holding a z lock (z not allowed)zCannot acquire write lock on z) from thread z while it is held by thread r   )
rw   r5   rM   r   r   rs   r   r7   r3   r
   )r|   r5   r   opposite	directionr`   curs   &&     r%   r   %SoftReadWriteLock._validate_reentrant  s   zz99"&&.wfH'+v~9I!$y0@BtH: V%%-Jgi[O  s##7?y':':'< <AUAUU//?{2d8* U"e#?@T@T?UW  s##

a
!t,,r$   c               (    V ^8  d   QhRRRRRRRR/# 	rL   r-   r   r   rQ   rD   r9   rR   ztuple[str, bool]r   )rT   s   "r%   rU   rj     s2     &( &(&( 	&(
 &( 
&(r$   c               	(  a a S P                  4        R  V V3R llpR V 3R llpS P                  WBVR7        S P                  WRVR7       S P                  P
                  R3#   \         d"    \        S P                  P
                  4       h i ; i)c                   V ^8  d   QhRR/# rL   rR   r9   r   )rT   s   "r%   rU   <SoftReadWriteLock._acquire_writer_slot.<locals>.__annotate__  s     		 		$ 		r$   c                   < S P                   P                  ;_uu_ 4        \        S P                  P                  S P
                  \        P                  ! 4       R 7       \        S P                  P                  4      '       d    RRR4       R#  \        S P                  P                  S4        RRR4       R#   \         d     RRR4       R# i ; i  + '       g   i     R# ; i)rH   nowNFT)
ru   r   _break_stale_markerrr   r   rH   r   _file_exists_atomic_create_markerFileExistsError)r|   r-   s   r%   try_claim_writer@SoftReadWriteLock._acquire_writer_slot.<locals>.try_claim_writer  s    """#DKK$5$5tG[G[aeajajalm 1 122  #"!)$++*;*;UC #  ' !  #"! #" s*   A&C B<<CCCCC'	c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   r     s     	/ 	/$ 	/r$   c            	       < S P                   P                  ;_uu_ 4        \        \        4      ;_uu_ 4        \	        S P
                  P                  4       R R R 4       S P                  \        P                  ! 4       4       S P                  4       '       * uuR R R 4       #   + '       g   i     LS; i  + '       g   i     R # ; iN)
ru   r   r   r   _touchrr   r   _break_stale_readersr   _any_readersr   s   r%   readers_drained_touchingHSoftReadWriteLock._acquire_writer_slot.<locals>.readers_drained_touching  sw    """ g&&4;;,,- '))$))+6,,.. #" '& #""s#   B6 B#	A B6#B3.B66C	r   F)_open_readers_dir	_wait_forr   r   rr   r   )r|   r-   r   rD   r   r   s   ff$$  r%   r   &SoftReadWriteLock._acquire_writer_slot  s     	 		 			/ 	/ 	'XN	NN3QYNZ
 {{  %''	  	DKK%%&	s   A% %,Bc               (    V ^8  d   QhRRRRRRRR/# r   r   )rT   s   "r%   rU   rj     s8     O OO 	O
 O 
Or$   c               	h  a aaaa S P                  4        \        P                  ! 4       P                   R \        P
                  ! 4        2oS P                  o\        \        S P                  P                  4      S,          4      oR VVVV V3R llpS P                  WBVR7       Se   SR3# SR3# ).c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   <SoftReadWriteLock._acquire_reader_slot.<locals>.__annotate__!  s     		 		$ 		r$   c                   < SP                   P                  ;_uu_ 4        \        SP                  P                  SP
                  \        P                  ! 4       R 7       \        SP                  P                  4      '       d    RRR4       R# S e   \        SSS R7       M\        SS4        RRR4       R#   + '       g   i     R# ; i)r   NFr   T)	ru   r   r   rr   r   rH   r   r   r   )r   full_reader_pathreader_namer|   r-   s   r%   try_claim_reader@SoftReadWriteLock._acquire_reader_slot.<locals>.try_claim_reader!  s    """#DKK$5$5tG[G[aeajajalm 1 122  #" %)+uVL)*:EB #"""s   A&B: B::C	r   T)r   uuiduuid4hexrp   getpidrv   r   r   rr   r   r   )r|   r-   r   rD   r   r   r   r   s   ff$$ @@@r%   r   &SoftReadWriteLock._acquire_reader_slot  s     	 ))*!BIIK=9%%tDKK$7$78;FG		 		 	'XN%1$NN7G$NNr$   c               (    V ^8  d   QhRRRRRRRR/# )	rL   	predicateCallable[[], bool]r   rQ   rD   r9   rR   ri   r   )rT   s   "r%   rU   rj   /  s2     " "%" 	"
 " 
"r$   c               	L    V! 4       '       d   R# \         P                  ! 4       pV'       g   \        V P                  4      hVe   WB8  d   \        V P                  4      hV P                  pVe   \        V\        W$,
          R4      4      p\         P                  ! V4       K  )TNg        )r   r   r   rM   rI   minmaxsleep)r|   r  r   rD   r   	sleep_fors   &&$$  r%   r   SoftReadWriteLock._wait_for/  s|     {{##%Cdnn--#dnn--**I#	3x~s+CD	JJy!r$   c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rj   C  s     G G4 Gr$   c                	   \        V P                  P                  4      p\        \        4      ;_uu_ 4        VP                  R R7       RRR4       \        P                  ! V P                  P                  4      p\        P                  ! VP                  4      '       g'   \        P                  ! VP                  4      '       g%   V P                  P                   R2p\        V4      hV P                  fr   \        '       dd   \        P                  \!        \        R^ 4      ,          \"        ,          p\        P$                  ! V P                  P                  V4      V n        R# R# R#   + '       g   i     EL,; i)i  )r5   NzB exists but is not a directory or is a symlink; refusing to use itO_DIRECTORY)r   rr   r   r   r   mkdirrp   lstatstatS_ISLNKst_modeS_ISDIRr   rv   _SUPPORTS_DIR_FDO_RDONLYgetattr_O_NOFOLLOWopen)r|   readers_pathstr`   flagss   &    r%   r   #SoftReadWriteLock._open_readers_dirC  s    DKK//0o&&E* ' XXdkk))*<<

##4<<

+C+C[[(())klCs##',<,<KK'"mQ"??+ME#%774;;+>+>#FD  -=' '&&s   E--E>	c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rj   Q  s      d r$   c                	6    V P                  4        F  p R # 	  R# )TF)_iter_reader_entries)r|   _s   & r%   r   SoftReadWriteLock._any_readersQ  s    **,A -r$   c                   V ^8  d   QhRR/# )rL   rR   zGenerator[tuple[str, bool]]r   )rT   s   "r%   rU   rj   V  s     @ @&A @r$   c              #  b  "   V P                   ej   \        P                  ! V P                   4      ;_uu_ 4       pV F0  p\        VP                  4      '       d   K   VP                  R3x  K2  	  RRR4       R# \        V P                  P                  4      p\        P                  ! V4      ;_uu_ 4       pV F?  p\        VP                  4      '       d   K   \        W2P                  ,          4      R3x  KA  	  RRR4       R#   + '       g   i     R# ; i  + '       g   i     R# ; i5i)a  
Yield ``(name, dirfd_relative)`` pairs for every live reader marker.

``dirfd_relative`` is ``True`` when *name* should be passed to ``dir_fd=``-aware syscalls; ``False``
when *name* is a full path because dirfd-relative I/O is unavailable on this platform.
NTF)	rv   rp   scandir_is_housekeeping_namer   r   rr   r   r   )r|   itentryr  s   &   r%   r  &SoftReadWriteLock._iter_reader_entriesV  s      +D0011RE0<<#jj$..   2 DKK//0ZZ%%,UZZ88lZZ78%??  &% 21 %%%sA   7D/DD0AD/7D#D=
D/D		D/D,	&	D/c                    V ^8  d   QhRRRR/# )rL   r   rP   rR   ri   r   )rT   s   "r%   rU   rj   i  s     ` ` `$ `r$   c                	    . p V P                  4        F+  w  r4TP                  Y4'       d   V P                  MR 34       K-  	  T F  w  r5\	        Y0P
                  YR7       K  	  R #   \         d     R # i ; i)N)rH   r   r   )r  appendrv   r   r   rH   )r|   r   namesr   dirfd_relativefds   &&    r%   r   &SoftReadWriteLock._break_stale_readersi  sr    .0	(,(A(A(C$dND$8$8PTUV )D HD6J6JPS_   		s   ?A' 'A65A6c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rj   s  s       r$   c                	    V P                   P                  ;_uu_ 4        V P                  pVf    R R R 4       R# VP                  pVP                  pVP
                  '       d   V P                  MR pR R R 4       \        XXR7      pVf   R# Vw  rgVe(   \        P                  ! VP                  X4      '       g   R#  \        W$R7       R#   + '       g   i     Lc; i  \         d     R# \         d     R# i ; i)NFr   T)ru   r)   rw   r8   r-   r:   rv   _read_markerhmaccompare_digestr   FileNotFoundErrorr   )r|   r   r8   r-   r   read_resultinfo_mtimes   &       r%   r   !SoftReadWriteLock._refresh_markers  s    [[!!!::D| "! **KJJE-1^^^T))F " #;v>" <t224::uEE	;.
 7 "!. ! 	 		s4   C)C%C C! C	!C=/C=8C=<C=c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rj     s     & &D &r$   c           	     	    \        \        P                  ! 4       \        P                  ! 4       \        V P                  P
                  RR7      R7      V n        RV n        RV n        RV n	        R# )   rn   ro   NTrd   )
r'   rs   rt   r   rr   r   ru   rw   rv   rx   r   s   &r%   _reset_after_fork_in_child,SoftReadWriteLock._reset_after_fork_in_child  sQ     ^^%!(t{{00"=

 
#!%r$   )ry   rx   rw   ru   rr   rv   rD   rF   rM   rI   rH   rO   rc   r   )"r   r   r    r!   r?   r	   rB   r"   rs   rt   rC   r}   r   r   r   r   r   r   r   classmethodr   r   r   r   r   r   r   r   r   r  r   r   r=  r#   r   r$   r%   rS   rS      s=   ,\ @S?TJ<Tnn&O0
 0 "0 %)0 )-0  $0 0d QU  & RV  &ATX A A.BUY B B6,"(&u (&T :
 : :* .D$-L-(&(PO4"(G
@&`<& &r$   rS   )	metaclassc                  :   a  ] tR tRtR V 3R lltR R ltRtV ;t# )r;   i  c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )rL   r   r  r   rP   r   r=   r   r   rR   ri   r   )rT   s   "r%   rU   _HeartbeatThread.__annotate__  s<     
& 
&#
& 
& $	
&
 
& 

&r$   c                	N   < \         SV `  VR R7       Wn        W n        W0n        R# )T)r   daemonN)rX   r}   _refresh	_interval_stop_event)r|   r   r   r   r   ra   s   &&&&&r%   r}   _HeartbeatThread.__init__  s'     	d40!%r$   c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rC    s      T r$   c                	    V P                   P                  V P                  4      '       g5   V P                  4       '       d   KC  V P                   P	                  4        R # R # r   )rH  waitrG  rF  r   r   s   &r%   run_HeartbeatThread.run  sB    ""''77==??  $$& 8r$   )rG  rF  rH  )r   r   r    r!   r}   rM  r#   re   rf   s   @r%   r;   r;     s    
& 
& r$   r;   r   c               (    V ^8  d   QhRRRRRRRR/# )rL   r   r   r-   r   r6   rR   ri   r   )rT   s   "r%   rU   rU     s)       C J RV r$   c               "   \         P                  \         P                  ,          \         P                  ,          \        ,          p\
        '       d   Ve   \         P                  ! WRVR7      pM\         P                  ! WR4      p V R\         P                  ! 4        R\        P                  ! 4        R2P                  R4      p\         P                  ! WE4       \         P                  ! V4       R #   \         P                  ! T4       i ; i)Ni  r   
ascii)rp   O_CREATO_EXCLO_WRONLYr  r  r  r   socketgethostnameencoder   r   )r   r-   r   r  r.  contents   &&$   r%   r   r     s     JJ"R[[0;>EF.WWT%7WWT%(G2biik]"V-?-?-A,B"ELLWU

s   AC6 6Dc               $    V ^8  d   QhRRRRRR/# )rL   r   r   r   r6   rR   z'tuple[_MarkerInfo | None, float] | Noner   )rT   s   "r%   rU   rU     s"     2 2s 2z 2=d 2r$   c               F   \         P                  \        ,          \        ,          p \        '       d   Ve   \         P
                  ! WVR7      M\         P
                  ! W4      p  \         P                  ! T4      p\         P                  ! T\        ^,           4      p \         P                  ! T4       \        T4      TP                  3#   \         d     R # i ; i  \         d     \         P                  ! T4       R # i ; i  \         P                  ! T4       i ; iNr   )rp   r  r  _O_NONBLOCKr  r  r   fstatr   _MAX_MARKER_SIZEr   _parse_marker_bytesst_mtime)r   r   r  r.  r  datas   &$    r%   r2  r2    s     KK+%3E4D4DI[RWWT0acahahimau	"B772/!34D 	t$bkk11    	
	 	s:   C 2C (8C  CC D+D DD D c                    V ^8  d   QhRRRR/# )rL   rb  bytesrR   z_MarkerInfo | Noner   )rT   s   "r%   rU   rU     s     R Re R(: Rr$   c                L   V '       d   \        V 4      \        8  d   R #  V P                  R4      p\        P
                  ! RT\        P                  4      pTf   R # \        TR,          ^
4      pTR8  d   R # \        TR,          Y2R,          R7      #   \         d     R # i ; i)NrR  u  
        \A                                  # start of string
        (?P<token>    [0-9a-f]{32}     ) \n # 128-bit hex token
        (?P<pid>      [1-9][0-9]{0,9}  ) \n # decimal pid: no leading zero, ≤ 10 digits
        (?P<hostname> [\x21-\x7e]{1,253})   # printable non-whitespace ASCII (RFC 1123 hostname limit)
        \n*                                 # tolerate sloppy writers that append extra newlines
        \Z                                  # end of string
        r/   r-   r0   )r-   r/   r0   i)	lenr_  decodeUnicodeDecodeErrorrematchVERBOSEr.   r,   )rb  textrj  r/   s   &   r%   r`  r`    s     3t9//{{7# HH	 	


E }
eElB
C
YU7^Z?PQQ'  s   B B#"B#c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
rL   r   r   rH   rP   r   r   r6   rR   r9   r   )rT   s   "r%   rU   rU     s<     * *
* * 
	*
 * 
*r$   c               n   \        WR 7      pVf   R# Vw  rVW&,
          V8:  d   R# Vf   \        WR 7       R# V  \         R\        P                  ! 4        R\
        P                  ! ^4       2p \        '       d   Ve   \        P                  ! WW3R7       M\        V 4      P                  V4        \        WsR 7      pVf   R# Vw  rV	f   \        WsR 7       R# \        P                  ! VP                  V	P                  4      '       g   R# W8  d   R# \        WsR 7       R#   \         d     R# i ; i)r   FTr   )
src_dir_fd
dst_dir_fd)r2  r   _BREAK_SUFFIXrp   r   r   r   r  renamer   r   r3  r4  r-   )r   rH   r   r   r6  info_beforemtime_before
break_name
read_after
info_aftermtime_afters   &$$$       r%   r   r     s    t3K +K
_,$6-"))+a8I8I"8M7NOJ 2IId6MJj) j8J(J
*{00*2B2BCC!J&  s   0D% <D% D% %D43D4c               $    V ^8  d   QhRRRRRR/# rL   r   r   r   r6   rR   ri   r   )rT   s   "r%   rU   rU   !  s!        #  *    r$   c                   \        \        4      ;_uu_ 4        \        '       d   Ve   \        P                  ! WR7       M\        V 4      P	                  4        R R R 4       R #   + '       g   i     R # ; ir\  )r   r5  r  rp   unlinkr   r   r   s   &$r%   r   r   !  sD    	#	$	$ 2IId*J 
%	$	$	$s   AA$$A5	c               $    V ^8  d   QhRRRRRR/# rz  r   )rT   s   "r%   rU   rU   *  s!        t r$   c                   \         '       d    Ve   \        P                  ! V R VR7       R # \        P                  ! V R 4       R # r\  )r  rp   utimer}  s   &$r%   r   r   *  s+    F.
tF+
tr$   c                    V ^8  d   QhRRRR/# )rL   pathr   rR   r9   r   )rT   s   "r%   rU   rU   1  s     $ $s $t $r$   c                     \         P                  ! V 4      p\        P                  ! TP
                  4      #   \         d     R # i ; i)F)rp   r  r5  r  S_ISREGr  )r  r  s   & r%   r   r   1  s=    XXd^ <<

##  s   8 AAc                    V ^8  d   QhRRRR/# )rL   r   r   rR   r9   r   )rT   s   "r%   rU   rU   9  s     9 9 9 9r$   c                F    V P                  R 4      ;'       g
    \        V 9   # )r   )
startswithrq  )r   s   &r%   r%  r%  9  s    ??388=D#88r$   c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rU   =  s     . .t .r$   c                     \         P                  ! 4       s\        \        P                  4       4       F  p V P                  4        K  	  R # r   )rs   rt   rz   listr   valuesr=  r_   s    r%   _reset_all_after_forkr  =  s5    
 $..*..01++- 2r$   c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rU   G  s     ) ) )r$   c                     \        \        P                  4       4       F5  p \        \        4      ;_uu_ 4        V P                  R R7       RRR4       K7  	  R#   + '       g   i     KL  ; i)Tr   N)r  r   r  r   	Exceptionr   r  s    r%   _cleanup_all_instancesr  G  sH    ..01i  4( !  2   s   AA*c                   V ^8  d   QhRR/# r   r   )rT   s   "r%   rU   rU   M  s          r$   c                     \         '       g   \        P                  ! \        4       R s \        '       g8   \        \        R4      '       d    \        P                  ! \        R7       R sR# R# R# )Tregister_at_fork)after_in_childN)	_atexit_registeredatexitregisterr  _fork_registeredhasattrrp   r  r  r   r$   r%   r{   r{   M  sL    ./!,> ? ?
+@A !@r$   )r   r   )K__conditional_annotations__r?   
__future__r   r  r3  rp   ri  r   rV  r  sysrs   r   r   
contextlibr   r   dataclassesr   pathlibr   typingr   r   weakrefr	   filelock._apir
   filelock._errorr   filelock._softr   filelock._utilr   collections.abcr   r   r4   rq  r_  r  r  r]  platformr  supports_dir_fdr  r   r"   rt   rz   r  r  r   r'   r,   r2   typerA   rS   Threadr;   r   r2  r`  r   r   r   r   r%  r  r  r{   __all__)r  s   @r%   <module>r     s   ` "   	 	    
    / !  ) ' , # ' 23 	  b,*b,* <<7*LLrww":L:L/L ?R?T< Tnn&    $      $   
$ 
$ 
$.$ .bZ&+ Z&zy'' ( 2D 2(R<*
 *Z t  d $9.)  r$   