
    ; j "                        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
  \(       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)zIAsync wrapper around :class:`SoftReadWriteLock` for use with ``asyncio``.    )annotationsN)asynccontextmanager)TYPE_CHECKING   )SoftReadWriteLock)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)$AsyncAcquireSoftReadWriteReturnProxy   zTAsync context-aware object that releases an :class:`AsyncSoftReadWriteLock` on exit.c                    Xl         g Nlock)selfr   s     i/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/filelock/_soft_rw/_async.py__init__-AsyncAcquireSoftReadWriteReturnProxy.__init__   s    	    c                "   #    U R                   $ 7fr   r   r   s    r   
__aenter__/AsyncAcquireSoftReadWriteReturnProxy.__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__.AsyncAcquireSoftReadWriteReturnProxy.__aexit__   s      ii!!!s   (&(r   N)r   AsyncSoftReadWriteLock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:    ^"," (" (	"
 
"r   r   c            	      p   \ rS rSrSr SSS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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%S jrSrg)&r#   %   a  
Async wrapper around :class:`SoftReadWriteLock` for ``asyncio`` applications.

The sync class's blocking filesystem operations run on a thread pool via ``loop.run_in_executor()``.
Reentrancy, upgrade/downgrade rules, fork handling, heartbeat and TTL stale detection, and singleton
behavior are delegated to the underlying :class:`SoftReadWriteLock`.

: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 :class:`SoftReadWriteLock` instances per 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``
:param poll_interval: seconds between acquire retries under contention; default 0.25 s
: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.27.0

Tg      >@Ng      ?)blockingis_singletonheartbeat_intervalstale_thresholdpoll_intervalloopexecutorc          
     D    [        UUUUUUUS9U l        Xl        Xl        g )N)r/   r0   r1   r2   r3   )r   _lock_loop	_executor)
r   	lock_filetimeoutr/   r0   r1   r2   r3   r4   r5   s
             r   r   AsyncSoftReadWriteLock.__init__;   s1     '%1+'

 
!r   c                .    U R                   R                  $ )z>:returns: the path to the lock file passed to the constructor.)r7   r:   r   s    r   r:    AsyncSoftReadWriteLock.lock_fileT   s     zz###r   c                .    U R                   R                  $ )zf:returns: the default timeout applied when ``acquire_read`` / ``acquire_write`` is called without one.)r7   r;   r   s    r   r;   AsyncSoftReadWriteLock.timeoutY   s     zz!!!r   c                .    U R                   R                  $ )zc:returns: whether ``acquire_*`` defaults to blocking; ``False`` makes contention raise immediately.)r7   r/   r   s    r   r/   AsyncSoftReadWriteLock.blocking^   s     zz"""r   c                    U R                   $ )zX:returns: the event loop used for ``run_in_executor``, or ``None`` for the running loop.)r8   r   s    r   r4   AsyncSoftReadWriteLock.loopc   s     zzr   c                    U R                   $ )zZ:returns: the executor used for ``run_in_executor``, or ``None`` for the default executor.)r9   r   s    r   r5   AsyncSoftReadWriteLock.executorh   s     ~~r   r/   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:`SoftReadWriteLock.acquire_read` for the full reentrancy / upgrade / fork semantics. The blocking
work runs inside ``run_in_executor`` so other coroutines on the same loop continue to progress while this
call waits.

: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

:returns: a proxy usable as an async context manager to release the lock

:raises RuntimeError: if a write lock is already held, 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

rG   Nr   )_runr7   acquire_readr   r   r;   r/   s      r   rJ   #AsyncSoftReadWriteLock.acquire_readm   s8     ( ii

//iLLL3>> 	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:`SoftReadWriteLock.acquire_write` for the two-phase writer-preferring semantics. The blocking
work runs inside ``run_in_executor``.

: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

:returns: a proxy usable as an async 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

rG   Nr   )rI   r7   acquire_writer   rK   s      r   rO   $AsyncSoftReadWriteLock.acquire_write   s8     & ii

00'iMMM3>> 	NrM   Fforcec               h   #    U R                  U R                  R                  US9I Sh  vN   g N7f)z
Release one level of the current 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``

rQ   N)rI   r7   r   )r   rR   s     r   r   AsyncSoftReadWriteLock.release   s'      ii

**%i888s   (202c                 #    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.

: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

rG   N)rJ   r   rK   s      r   	read_lock AsyncSoftReadWriteLock.read_lock   sN      ;;;	!,,.  	 	< !$,,.  <   A9A= A;AAAAAAc                 #    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.

: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

rG   N)rO   r   rK   s      r   
write_lock!AsyncSoftReadWriteLock.write_lock   sN         <<<	!,,.  	 	= !$,,.  rX   c                j   #    U R                  U R                  R                  5      I Sh  vN   g N7f)zRRelease any held lock and release the underlying filesystem resources. Idempotent.N)rI   r7   closer   s    r   r]   AsyncSoftReadWriteLock.close   s!     ii

(()))s   )313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   )r8   asyncioget_running_looprun_in_executorr9   	functoolspartial)r   funcargskwargsr4   s        r   rI   AsyncSoftReadWriteLock._run   sP     zz7W557))$..):K:KD:bSW:b[a:bccccs   A A)"A'#A))r9   r7   r8   ))r:   zstr | os.PathLike[str]r;   floatr/   boolr0   rk   r1   rj   r2   float | Noner3   rj   r4    asyncio.AbstractEventLoop | Noner5   futures.Executor | Noner$   r%   )r$   str)r$   rj   )r$   rk   )r$   rm   )r$   rn   r   )r;   rl   r/   bool | Noner$   r   )rR   rk   r$   r%   )r;   rl   r/   rp   r$   zAsyncGenerator[None])r$   r%   )re   zCallable[..., object]rf   objectrg   rq   r$   rq   )r&   r'   r(   r)   r*   r   propertyr:   r;   r/   r4   r5   rJ   rO   r   r   rV   rZ   r]   rI   r+   r,   r   r   r#   r#   %   s   0 "
 !$((,#15,0")" "
 " " "" &" " /" *" 
"2 $ $ " " # #    
 '+?GK?#?9D?	-?0 '+?GK?#?9D?	-?, .3 	9 !W[ ! !" !X\ ! !"*dr   r#   )r*   
__future__r   r`   rc   
contextlibr   typingr   _syncr   oscollections.abcr   r	   
concurrentr
   typesr   r   r#   __all__r,   r   r   <module>r|      sQ    O "   *   $8"#" "$jd jd\ +r   