+
    ~j;                    ~  a  0 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
HtHt ^ RIHtHt ^ RIHt ^RIHt ^RIHt ]'       d   ^ RIHt ]P0                  ! R	4      t]! 4       tR
]R&   ]P:                  ! 4       tR R lt]P@                  ! ]4       Rt!R R lt" ! R R]#4      t$ ! R R]$R7      t%R# )    )annotationsN)contextmanagersuppress)TYPE_CHECKINGLiteral)WeakValueDictionary)AcquireReturnProxy)Timeout)	Generatorfilelockzset[sqlite3.Connection]_all_connectionsc                   V ^8  d   QhRR/#    returnNone )formats   "i/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/filelock/_read_write.py__annotate__r      s     ! !d !    c            
     8   \         ;_uu_ 4        \        \        4       F3  p \        \        4      ;_uu_ 4        V P                  4        R R R 4       K5  	  \        P                  4        R R R 4       R #   + '       g   i     Kf  ; i  + '       g   i     R # ; iN)_all_connections_locklistr   r   	Exceptioncloseclear)cons    r   _cleanup_connectionsr       s`    		()C)$$		 %$ * 	 	 
	$$$ 
		s"   *BA4
 B4B?	BB	c               (    V ^8  d   QhRRRRRRRR/# )r   timeoutfloatblockingboolalready_waitedr   intr   )r   s   "r   r   r   (   s)       D % TW r   c                  VR J d   ^ # V R8X  d   \         # V ^ 8  d   Rp\        V4      hV ^ 8  d   \        W,
          ^ 4      MT p\        VR,          4      pV\         8  g   V^ 8  d"   \        P                  RV \         4       \         # V# )Fz+timeout must be a non-negative number or -1i  z7timeout %s is too large for SQLite, using %s ms instead)_MAX_SQLITE_TIMEOUT_MS
ValueErrormaxr'   _LOGGERwarning)r"   r$   r&   msg	remaining
timeout_mss   &$$   r   timeout_for_sqliter2   (   s    5"}%%{;o4;aKG,a0WIY%&J**j1nQSZ\rs%%r   c                  X   a  ] tR t^;t$ RtR]R&   R]R&   RRRRR/R	 V 3R
 lllltRtV ;t# )_ReadWriteLockMetaa  
Metaclass that handles singleton resolution when is_singleton=True.

Singleton logic lives here rather than in ReadWriteLock.get_lock so that ``ReadWriteLock(path)`` transparently
returns cached instances without a 2-arg ``super()`` call that type checkers cannot verify.

0WeakValueDictionary[pathlib.Path, ReadWriteLock]
_instanceszthreading.Lock_instances_lockr$   Tis_singletonc          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   	lock_filestr | os.PathLike[str]r"   r#   r$   r%   r8   r   ReadWriteLockr   )r   s   "r   r   _ReadWriteLockMeta.__annotate__G   s<      ) 
   
r   c          
     	  < V'       g   \         SV `  WW4R 7      # \        P                  ! V4      P	                  4       pV P
                  ;_uu_ 4        WPP                  9  d!   \         SV `  WW4R 7      pW`P                  V&   MV P                  V,          pV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))r$   r8   z$Singleton lock created with timeout=z, blocking=z, cannot be changed to timeout=N)
super__call__pathlibPathresolver7   r6   r"   r$   r+   )	clsr:   r"   r$   r8   
normalizedinstancer/   	__class__s	   &&&$$   r   r@   _ReadWriteLockMeta.__call__G   s     7#I#ee\\),446
   / 7+I+m-5z*>>*57*h.?.?8.K:8;K;K:LKX`XiXiWj k55<I[
T  !o% !   s   BC22D	r   r)   )	__name__
__module____qualname____firstlineno____doc____annotations__r@   __static_attributes____classcell__)rG   s   @r   r4   r4   ;   s:     A@##
  "  r   r4   c                  X   ] tR t^ct$ Rt]! 4       tR]R&   ]P                  ! 4       t
]R#RR/R R lll4       tR#RRRR/R	 R
 llltR R ltR R ltR R ltR R ltR#RR/R R llltR#RR/R R llltRR/R R llt]R$RR/R R lll4       t]R$RR/R R lll4       tR  R! ltR"tR# )%r<   a  
Cross-process read-write lock backed by SQLite.

Allows concurrent shared readers or a single exclusive writer. The lock is reentrant within the same mode (multiple
``acquire_read`` calls nest, as do multiple ``acquire_write`` calls from the same thread), but upgrading from read
to write or downgrading from write to read raises :class:`RuntimeError`. Write locks are pinned to the thread that
acquired them.

By default, ``is_singleton=True``: calling ``ReadWriteLock(path)`` with the same resolved path returns the same
instance. The lock file must use a ``.db`` extension (SQLite database).

:param lock_file: path to the SQLite database file used as the lock
: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
:param is_singleton: if ``True``, reuse existing instances for the same resolved path

.. versionadded:: 3.21.0

r5   r6   r$   Tc               (    V ^8  d   QhRRRRRRRR/# )	r   r:   r;   r"   r#   r$   r%   r   r<   r   )r   s   "r   r   ReadWriteLock.__annotate__|   s,     : :.:9>:RV:	:r   c                   V ! WVR7      # )a  
Return the singleton :class:`ReadWriteLock` for *lock_file*.

:param lock_file: path to the SQLite database file used as the lock
: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   )rD   r:   r"   r$   s   &&&$r   get_lockReadWriteLock.get_lock{   s      999r   r8   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   r:   r;   r"   r#   r$   r%   r8   r   r   r   )r   s   "r   r   rT      s<     , ,), ,
 , , 
,r   c               	   \         P                  ! V4      V n        W n        W0n        \
        P                  ! 4       V n        \
        P                  ! 4       V n        ^ V n	        RV n
        RV n        \        P                  ! V P                  RR7      V n        \        ;_uu_ 4        \         P#                  V P                  4       RRR4       R#   + '       g   i     R# ; i)r   NF)check_same_thread)osfspathr:   r"   r$   	threadingLock_transaction_lock_internal_lock_lock_level_current_mode_write_thread_idsqlite3connect_conr   r   add)selfr:   r"   r$   r8   s   &&&$$r   __init__ReadWriteLock.__init__   s     9- !*!1'nn.>B,0OODNNeL	""  + #"""s   & CC!	c               $    V ^8  d   QhRRRRRR/# )r   r$   r%   r"   r#   r   r   r   )r   s   "r   r   rT      s!     4 4T 4E 4d 4r   c               	   V'       g   V P                   P                  R R7      pMAVR8X  d   V P                   P                  RR7      pMV P                   P                  RVR7      pV'       g   \        V P                  4      RhR# )FrV   Tr$   r"   Nr)   )r`   acquirer
   r:   )ri   r$   r"   acquireds   &$$ r   _acquire_transaction_lock'ReadWriteLock._acquire_transaction_lock   sr    --55u5EH]--55t5DH--55tW5UH$..)t3 r   c               (    V ^8  d   QhRRRRRRRR/# )r   modeLiteral['read', 'write']oppositestr	directionr   r	   r   )r   s   "r   r   rT      s+     - -(@ -C -\_ -dv -r   c                	   V P                   V8w  d1   R V RV P                   R\        V 4       RV RV R2p\        V4      hVR8X  d\   \        P
                  ! 4       ;qPP                  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      # )zCannot acquire z	 lock on  (lock id: z): already holding a z lock (z not allowed)writezCannot acquire write lock on z) from thread z while it is held by thread lock)	rc   r:   idRuntimeErrorr^   	get_identrd   rb   r	   )ri   rt   rv   rx   r/   curs   &&&&  r   _validate_reentrant!ReadWriteLock._validate_reentrant   s    %!$y0@BtH: V%%-Jgi[O  s##7?y':':'< <AVAVV//?{2d8* U"e#?@U@U?VX  s##A!t,,r   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   rt   ru   r"   r#   r$   r%   
start_timer   r   r   )r   s   "r   r   rT      s;     Q Q,Q7<QKOQ]bQ	Qr   c               	   \         P                  ! 4       V,
          p\        W#VR 7      pV P                  P	                  RV R24      P                  4        V P                  P	                  R4      P                  4        \         P                  ! 4       V,
          p\        W#VR 7      ;qv8w  d.   V P                  P	                  RV R24      P                  4        VR8X  d   RMRpV P                  P	                  V4      P                  4        VR8X  d,   V P                  P	                  R4      P                  4        R	# R	# )
)r$   r&   zPRAGMA busy_timeout=;zPRAGMA journal_mode=MEMORY;r{   zBEGIN EXCLUSIVE TRANSACTION;zBEGIN TRANSACTION;readz'SELECT name FROM sqlite_schema LIMIT 1;N)timeperf_counterr2   rg   executer   )	ri   rt   r"   r$   r   waitedr1   
recomputedstmts	   &&&$$    r   _configure_and_begin"ReadWriteLock._configure_and_begin   s    ""$z1'SYZ
		0A>?EEG 			78>>@""$z1,WX^__JnII 4ZLBCIIK15-FZ		$%%'6> IIGHNNP r   c               (    V ^8  d   QhRRRRRRRR/# )	r   rt   ru   r"   r#   r$   r%   r   r	   r   )r   s   "r   r   rT      s+     - -5 - -TX -]o -r   c               	    VR 8X  d   RMR pVR 8X  d   RMRpV P                   ;_uu_ 4        V P                  ^ 8  d   V P                  WV4      uuRRR4       #  RRR4       \        P                  ! 4       pV P                  W2R7        V P                   ;_uu_ 4        V P                  ^ 8  d7   V P                  WV4      uuRRR4       V P                  P                  4        #  RRR4       V P                  WW6R7       V P                   ;_uu_ 4        Wn	        ^V n        VR8X  d   \        P                  ! 4       V n        RRR4       \        V R7      V P                  P                  4        #   + '       g   i     EL"; i  + '       g   i     L; i  + '       g   i     L]; i  \        P                   d-   pR\!        T4      9  d   h \#        T P$                  4      RhRp?ii ; i  T P                  P                  4        i ; i)	r   r{   	downgradeupgradeNrn   )r$   r   r|   zdatabase is locked)ra   rb   r   r   r   rq   r`   releaser   rc   r^   r   rd   r	   re   OperationalErrorrw   r
   r:   )ri   rt   r"   r$   rv   rx   r   excs   &&&$    r   _acquireReadWriteLock._acquire   s   "fn7&#'6>Ky	   !#//	J ! # ! &&(
&&&J	-$$$##a'33DIN %$& ""**,% ( % %%dh%^$$$%)"#$ 7?,5,?,?,AD)	 % &40 ""**,7 !   %$ %$ '' 	4#3s83$..)t3	4
 ""**,se   #E3
F- #F
F- '/F- /FF- 3F	F	F- F*	%F- -G.'G))G..G1 1Hc               $    V ^8  d   QhRRRRRR/# r   r"   r#   r$   r%   r   r	   r   )r   s   "r   r   rT      s'     A AE AT AM_ Ar   c               (    V P                  RWR7      # )a  
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).

: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: 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
:raises Timeout: if the lock cannot be acquired within *timeout* seconds

r   rV   r   ri   r"   r$   s   &&$r   acquire_readReadWriteLock.acquire_read   s      }}VW}@@r   c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   rT     s'     B BU Bd BN` 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`.

: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: a proxy that can be used as a context manager to release the lock

: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{   rV   r   r   s   &&$r   acquire_writeReadWriteLock.acquire_write  s    $ }}Wg}AAr   forceFc                    V ^8  d   QhRRRR/# )r   r   r%   r   r   r   )r   s   "r   r   rT     s     ! ! ! !r   c                  RpV P                   ;_uu_ 4        V P                  ^ 8X  d;   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                  ^ 8X  d   RV n        RV n        RpRRR4       V'       d   V P                  P                  4        R# R#   + '       g   i     L6; i)aD  
Release one level of the current lock.

When the lock level reaches zero the underlying SQLite transaction is rolled back, releasing the database lock.

: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``

FNzCannot release a lock on rz   z) that is not heldT)	ra   rb   r:   r~   r   rc   rd   rg   rollback)ri   r   should_rollbackr/   s   &$  r   r   ReadWriteLock.release  s         1$ !  2$..1ARPTXJVhi"3''#$   A% 1$%)"(,%"& ! II   ! s   CC.C+ACC+	Nc               $    V ^8  d   QhRRRRRR/# r   r"   zfloat | Noner$   zbool | Noner   zGenerator[None]r   )r   s   "r   r   rT   9  s"       ; Zi r   c             #     "   Vf   V P                   pVf   V P                  pV P                  WR7        Rx  V P                  4        R#   T P                  4        i ; i5i)aU  
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

NrV   )r"   r$   r   r   r   s   &&$r   	read_lockReadWriteLock.read_lock8  sO      ?llG}}H'5	LLNDLLN   3A!A A!AA!c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   rT   N  s"      , K [j r   c             #     "   Vf   V P                   pVf   V P                  pV P                  WR7        Rx  V P                  4        R#   T P                  4        i ; i5i)aZ  
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

NrV   )r"   r$   r   r   r   s   &&$r   
write_lockReadWriteLock.write_lockM  sO      ?llG}}H76	LLNDLLNr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rT   b  s     
0 
0t 
0r   c                    V P                  RR7       V P                  P                  4        \        ;_uu_ 4        \        P                  V P                  4       RRR4       R#   + '       g   i     R# ; i)z
Release the lock (if held) and close the underlying SQLite connection.

After calling this method, the lock instance is no longer usable.

T)r   N)r   rg   r   r   r   discard)ri   s   &r   r   ReadWriteLock.closeb  sG     	4 		""$$TYY/ #"""s    A%%A6	)	rg   rc   ra   rb   r`   rd   r$   r:   r"   rI   r   )rJ   rK   rL   rM   rN   r   r6   rO   r^   r_   r7   classmethodrW   rj   rq   r   r   r   r   r   r   r   r   r   r   rP   r   r   r   r<   r<   c   s    ( DWCXJ@Xnn&O:Y]: :",
 , ", ,(4- Q2-BAD A A$BT B B(!u !: QU  ( RV  (
0 
0r   r<   )	metaclassi5w)&__conditional_annotations__
__future__r   atexitloggingr\   rA   re   r^   r   
contextlibr   r   typingr   r   weakrefr   _apir	   _errorr
   collections.abcr   	getLoggerr-   setr   rO   r_   r   r    registerr*   r2   typer4   r<   )r   s   @r   <module>r      s    " "   	     / ) ' $ )


J
',/E ) 1!( ! $ % + &% %PI00 I0r   