
    *pj,                    
   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	J
r
Jr  SSKJrJrJrJrJrJr  SSKJr  \	(       a  SS	KJrJr  SS
KJr  SSKJr  SSKJr  \
" S5      r\" S5      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	ParamSpecTypeVar)_BackendOutcome_capture_call_drain_future_future_result_raise_cancelled_error_wait_until_done   )SoftReadWriteLock)AsyncGeneratorCallable)futures)TracebackType)AcquireReturnProxy_P_Rc            	         \ 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5       r\S#SS.S$S jj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 jrS'S jrS(S jrS)S jr        S*S jrSrg)+AsyncSoftReadWriteLock!   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()``. The
underlying :class:`SoftReadWriteLock` handles reentrancy, upgrade/downgrade rules, fork handling, heartbeat and
TTL stale detection, and singleton behavior.

: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          
     x    [         R                  " 5       U l        [        UUUUUUUS9U l        Xl        Xl        g )N)r   r   r   r   r   )osgetpid_creator_pidr   _lock_loop	_executor)
self	lock_filetimeoutr   r   r   r   r   r   r    s
             T/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/filelock/_soft_rw/_async.py__init__AsyncSoftReadWriteLock.__init__7   s?     IIK&%1+'

 
!    c                .    U R                   R                  $ )z4The path to the lock file passed to the constructor.)r%   r)   r(   s    r+   r)    AsyncSoftReadWriteLock.lock_fileQ   s     zz###r.   c                .    U R                   R                  $ )z\The default timeout applied when ``acquire_read`` / ``acquire_write`` is called without one.)r%   r*   r0   s    r+   r*   AsyncSoftReadWriteLock.timeoutV   s     zz!!!r.   c                .    U R                   R                  $ )zYWhether ``acquire_*`` defaults to blocking; ``False`` makes contention raise immediately.)r%   r   r0   s    r+   r   AsyncSoftReadWriteLock.blocking[   s     zz"""r.   c                    U R                   $ )zNThe event loop used for ``run_in_executor``, or ``None`` for the running loop.)r&   r0   s    r+   r   AsyncSoftReadWriteLock.loop`   s     zzr.   c                    U R                   $ )zPThe executor used for ``run_in_executor``, or ``None`` for the default executor.)r'   r0   s    r+   r    AsyncSoftReadWriteLock.executore   s     ~~r.   r   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

r:   N)acquire_readreleaser(   r*   r   s      r+   	read_lock AsyncSoftReadWriteLock.read_lockj   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

r:   N)acquire_writer=   r>   s      r+   
write_lock!AsyncSoftReadWriteLock.write_lock|   sN         <<<	!,,.  	 	= !$,,.  rA   c                  #    U R                  5         U R                  [        R                  " U R                  R
                  XS95      I Sh  vN   [        U S9$  N7f)a  
Acquire a shared read lock.

See :meth:`SoftReadWriteLock.acquire_read` for reentrancy / upgrade / fork semantics. The blocking work runs
inside ``run_in_executor`` so other coroutines on the same loop keep progressing 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

r:   Nlock)_raise_if_inherited_run_acquire	functoolspartialr%   r<   $AsyncAcquireSoftReadWriteReturnProxyr>   s      r+   r<   #AsyncSoftReadWriteLock.acquire_read   sO     & 	  "	 1 1$**2I2I7 fggg3>> 	h   AAAAc                  #    U R                  5         U R                  [        R                  " U R                  R
                  XS95      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

r:   NrG   )rI   rJ   rK   rL   r%   rC   rM   r>   s      r+   rC   $AsyncSoftReadWriteLock.acquire_write   sO     & 	  "	 1 1$**2J2JG ghhh3>> 	irO   Fforcec                  #    U R                   [        R                  " 5       :X  a-  U R                  U R                  R
                  US9I Sh  vN   g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``

rR   N)r$   r"   r#   _runr%   r=   )r(   rS   s     r+   r=   AsyncSoftReadWriteLock.release   sC      		+))DJJ..e)<<< ,<s   AAAAc                   #    U R                   [        R                  " 5       :X  a.  U R                  U R                  R
                  5      I Sh  vN   gg N7f)zRRelease any held lock and release the underlying filesystem resources. Idempotent.N)r$   r"   r#   rU   r%   closer0   s    r+   rX   AsyncSoftReadWriteLock.close   s=     		+))DJJ,,--- ,-s   AAAAc                    U R                   [        R                  " 5       :w  a  SU R                   S3n[	        U5      eg )NzAsyncSoftReadWriteLock on z4 was inherited across fork; construct a new instance)r$   r"   r#   r)   RuntimeError)r(   msgs     r+   rI   *AsyncSoftReadWriteLock._raise_if_inherited   s:    		+.t~~.>>rsCs## ,r.   c                  #    U R                  U5      n [        U5      I S h  vN   [        U5        g  N! [        R                   a  n [	        U5      I S h  vN    O"! [
         a  n[        X45         S nAOS nAff = f [	        U R                  U R                  R                  5      5      I S h  vN    e ! [
         a  n[        X45         S nAe S nAff = fS nAff = f7fN)
_submitr   asyncioCancelledErrorr
   BaseExceptionr   r%   r=   r   )r(   acquireacquire_futurecancellationerrors        r+   rJ   #AsyncSoftReadWriteLock._run_acquire   s     
 g.	">222 	~& 3%% 		<#N333  <&|;;<<#DLL1C1C$DEEE  ! <&|;;<		s   C%6 46 C%6 C"A AA C 
A?*A:5C:A??C1B;4B75B;:C;
CCCCCC""C%c                   #    U R                   " U/UQ70 UD6n [        U5      I S h  vN   [        U5      $  N! [        R                   a=  n [	        U5      I S h  vN    e ! [
         a  n[        XV5         S nAe S nAff = fS nAff = f7fr_   )r`   r   ra   rb   r
   rc   r   r   )r(   funcargskwargsfuturerf   rg   s          r+   rU   AsyncSoftReadWriteLock._run   s      d4T4V4	"6*** f%% +%% 	<#F+++  ! <&|;;<	sa   B: 8: B: BA$A A$#B$
B.A>9B>BBBBc           	         U R                   =(       d    [        R                  " 5       nUR                  U R                  [
        [        R                  " U/UQ70 UD65      $ r_   )r&   ra   get_running_looprun_in_executorr'   r	   rK   rL   )r(   rj   rk   rl   r   s        r+   r`   AsyncSoftReadWriteLock._submit   sL     zz7W557##DNNM9CTCTUYCk\`CkdjCkllr.   )r$   r'   r%   r&   ))r)   zstr | os.PathLike[str]r*   floatr   boolr   ru   r   rt   r   float | Noner   rt   r    asyncio.AbstractEventLoop | Noner    futures.Executor | NonereturnNone)ry   str)ry   rt   )ry   ru   )ry   rw   )ry   rx   r_   )r*   rv   r   bool | Nonery   zAsyncGenerator[None])r*   rv   r   r|   ry   rM   )rS   ru   ry   rz   )ry   rz   )rd   z Callable[[], AcquireReturnProxy]ry   rz   )rj   Callable[_P, _R]rk   _P.argsrl   	_P.kwargsry   r   )rj   r}   rk   r~   rl   r   ry   z#asyncio.Future[_BackendOutcome[_R]])__name__
__module____qualname____firstlineno____doc__r,   propertyr)   r*   r   r   r    r   r?   rD   r<   rC   r=   rX   rI   rJ   rU   r`   __static_attributes__ r.   r+   r   r   !   s   0 "
 !$((,#15,0")" "
 " " "" &" " /" *" 
"4 $ $ " " # #     !W[ ! !" !X\ ! !$ '+?GK?#?9D?	-?0 '+?GK?#?9D?	-?. .3 
=.
$
'(&m$m-4m@Im	,mr.   r   c                  F    \ rS rSrSrSS jrS	S jr        S
S jrSrg)rM      zTAsync context-aware object that releases an :class:`AsyncSoftReadWriteLock` on exit.c                    Xl         g r_   rG   )r(   rH   s     r+   r,   -AsyncAcquireSoftReadWriteReturnProxy.__init__   s    	r.   c                "   #    U R                   $ 7fr_   rG   r0   s    r+   
__aenter__/AsyncAcquireSoftReadWriteReturnProxy.__aenter__  s     yys   c                T   #    U R                   R                  5       I S h  vN   g  N7fr_   )rH   r=   )r(   exc_type	exc_value	tracebacks       r+   	__aexit__.AsyncAcquireSoftReadWriteReturnProxy.__aexit__  s      ii!!!s   (&(rG   N)rH   r   ry   rz   )ry   r   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Nonery   rz   )	r   r   r   r   r   r,   r   r   r   r   r.   r+   rM   rM      s:    ^"," (" (	"
 
"r.   rM   )#r   
__future__r   ra   rK   r"   
contextlibr   typingr   r   r   filelock._asyncr   r	   r
   r   r   r   _syncr   collections.abcr   r   
concurrentr   typesr   filelock._apir   r   r   r   rM   __all__r   r.   r+   <module>r      su    O "   	 * 4 4  %8"#0t_T]Wm Wmt" "& +r.   