
    ; jO                        S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  \
(       a  SSKrSS	KJrJr  SS
KJr  SSKJr   " S S5      r " S S5      rSS/rg)zEAsync wrapper around :class:`ReadWriteLock` for use with ``asyncio``.    )annotationsN)ThreadPoolExecutor)asynccontextmanager)TYPE_CHECKING   )ReadWriteLock)AsyncGeneratorCallable)futures)TracebackTypec                  F    \ rS rSrSrSS jrS	S jr        S
S jrSrg) AsyncAcquireReadWriteReturnProxy   zEContext-aware object that releases the async read/write lock on exit.c                    Xl         g Nlock)selfr   s     k/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/filelock/_async_read_write.py__init__)AsyncAcquireReadWriteReturnProxy.__init__   s    	    c                "   #    U R                   $ 7fr   r   r   s    r   
__aenter__+AsyncAcquireReadWriteReturnProxy.__aenter__   s     yys   c                T   #    U R                   R                  5       I S h  vN   g  N7fr   )r   release)r   exc_type	exc_value	tracebacks       r   	__aexit__*AsyncAcquireReadWriteReturnProxy.__aexit__   s      ii!!!s   (&(r   N)r   AsyncReadWriteLockreturnNone)r%   r$   )r   ztype[BaseException] | Noner    zBaseException | Noner!   zTracebackType | Noner%   r&   )	__name__
__module____qualname____firstlineno____doc__r   r   r"   __static_attributes__ r   r   r   r      s:    O"," (" (	"
 
"r   r   c                  F   \ rS rSrSr SSSSSS.             SS jjjr\SS j5       r\SS j5       r\SS	 j5       r	\SS
 j5       r
\SS j5       rSS jrSSS.SS jjjrSSS.SS jjjrSS.S S jjr\S!SS.S"S jjj5       r\S!SS.S"S jjj5       rS#S jrSrg)$r$   &   a  
Async wrapper around :class:`ReadWriteLock` for use in ``asyncio`` applications.

Because Python's :mod:`sqlite3` module has no async API, all blocking SQLite operations are dispatched to a thread
pool via ``loop.run_in_executor()``. Reentrancy, upgrade/downgrade rules, and singleton behavior are delegated
to the underlying :class:`ReadWriteLock`.

: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 :class:`ReadWriteLock` instances for the same resolved path
:param loop: event loop for ``run_in_executor``; ``None`` uses the running loop
:param executor: executor for ``run_in_executor``; ``None`` uses the default executor

.. versionadded:: 3.21.0

TN)blockingis_singletonloopexecutorc               n    [        XX4S9U l        XPl        US L U l        U=(       d	    [	        SS9U l        g )N)r0   r1   r   )max_workers)r   _lock_loop_owns_executorr   	_executor)r   	lock_filetimeoutr0   r1   r2   r3   s          r   r   AsyncReadWriteLock.__init__9   s6     #9d

&$.!F%7A%Fr   c                .    U R                   R                  $ )z$:returns: the path to the lock file.)r6   r:   r   s    r   r:   AsyncReadWriteLock.lock_fileH   s     zz###r   c                .    U R                   R                  $ )z:returns: the default timeout.)r6   r;   r   s    r   r;   AsyncReadWriteLock.timeoutM   s     zz!!!r   c                .    U R                   R                  $ )z1:returns: whether blocking is enabled by default.)r6   r0   r   s    r   r0   AsyncReadWriteLock.blockingR   s     zz"""r   c                    U R                   $ )z<:returns: the event loop (or ``None`` for the running loop).)r7   r   s    r   r2   AsyncReadWriteLock.loopW   s     zzr   c                    U R                   $ )z5:returns: the executor (or ``None`` for the default).)r9   r   s    r   r3   AsyncReadWriteLock.executor\   s     ~~r   c                   #    U R                   =(       d    [        R                  " 5       nUR                  U R                  [
        R                  " U/UQ70 UD65      I S h  vN $  N7fr   )r7   asyncioget_running_looprun_in_executorr9   	functoolspartial)r   funcargskwargsr2   s        r   _runAsyncReadWriteLock._runa   sP     zz7W557))$..):K:KD:bSW:b[a:bccccs   A A)"A'#A)r0   c               x   #    U R                  U R                  R                  XS9I Sh  vN   [        U S9$  N7f)a  
Acquire a shared read lock.

See :meth:`ReadWriteLock.acquire_read` for full semantics.

: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 an async 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

rR   Nr   )rP   r6   acquire_readr   r   r;   r0   s      r   rT   AsyncReadWriteLock.acquire_reade   s8      ii

//iLLL/T:: 	M   (:8:c               x   #    U R                  U R                  R                  XS9I Sh  vN   [        U S9$  N7f)a  
Acquire an exclusive write lock.

See :meth:`ReadWriteLock.acquire_write` for full semantics.

: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 an async 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

rR   Nr   )rP   r6   acquire_writer   rU   s      r   rY    AsyncReadWriteLock.acquire_writew   s8      ii

00'iMMM/T:: 	NrW   Fforcec               h   #    U R                  U R                  R                  US9I Sh  vN   g N7f)a
  
Release one level of the current lock.

See :meth:`ReadWriteLock.release` for full semantics.

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

r[   N)rP   r6   r   )r   r\   s     r   r   AsyncReadWriteLock.release   s'      ii

**%i888s   (202c                #    Uc  U R                   R                  nUc  U R                   R                  nU R                  XS9I Sh  vN    S7v   U R	                  5       I Sh  vN   g N# N! U R	                  5       I Sh  vN    f = f7f)a[  
Async 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

NrR   )r6   r;   r0   rT   r   rU   s      r   	read_lockAsyncReadWriteLock.read_lock   sw      ?jj((Gzz**H;;;	!,,.  	 	< !$,,.  H   ABA+BA/ B%A-&B-B/B
BB

Bc                #    Uc  U R                   R                  nUc  U R                   R                  nU R                  XS9I Sh  vN    S7v   U R	                  5       I Sh  vN   g N# N! U R	                  5       I Sh  vN    f = f7f)a`  
Async 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

NrR   )r6   r;   r0   rY   r   rU   s      r   
write_lockAsyncReadWriteLock.write_lock   sw      ?jj((Gzz**H   <<<	!,,.  	 	= !$,,.  rb   c                   #    U R                  U R                  R                  5      I Sh  vN   U R                  (       a  U R                  R                  SS9  gg N07f)z
Release the lock (if held) and close the underlying SQLite connection.

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

NF)wait)rP   r6   closer8   r9   shutdownr   s    r   rh   AsyncReadWriteLock.close   sK      ii

(()))NN###/  	*s   )AA1A)r9   r6   r7   r8   ))r:   zstr | os.PathLike[str]r;   floatr0   boolr1   rm   r2    asyncio.AbstractEventLoop | Noner3   futures.Executor | Noner%   r&   )r%   str)r%   rl   )r%   rm   )r%   rn   )r%   ro   )rM   zCallable[..., object]rN   objectrO   rq   r%   rq   )r;   rl   r0   rm   r%   r   )r\   rm   r%   r&   r   )r;   zfloat | Noner0   zbool | Noner%   zAsyncGenerator[None])r%   r&   )r'   r(   r)   r*   r+   r   propertyr:   r;   r0   r2   r3   rP   rT   rY   r   r   r`   rd   rh   r,   r-   r   r   r$   r$   &   sD   * G
 !15,0G)G G
 G G /G *G 
G $ $ " " # #    d;$ ; ;$;4 ; ;$ .3 9 !W[ ! !( !X\ ! !(	0r   r$   )r+   
__future__r   rH   rK   concurrent.futuresr   
contextlibr   typingr   _read_writer   oscollections.abcr	   r
   
concurrentr   typesr   r   r$   __all__r-   r   r   <module>r}      sR    K "   1 *   &8"#" "$c0 c0N 'r   