Ë
    ­Ó^j$  ã                  óÔ   — d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
mZ ddlmZ e	rddlmZmZ dd	lmZ dd
lmZ  e
d«      Z ed«      Z G d„ d«      Z G d„ d«      ZddgZy)zIAsync wrapper around :class:`SoftReadWriteLock` for use with ``asyncio``.é    )ÚannotationsN)Úasynccontextmanager)ÚTYPE_CHECKINGÚ	ParamSpecÚTypeVaré   )ÚSoftReadWriteLock)ÚAsyncGeneratorÚCallable)Úfutures)ÚTracebackTypeÚ_PÚ_Rc            	      ó@  — e Zd ZdZ	 dddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zedd„«       Zedd	„«       Zedd
„«       Zedd„«       Z	edd„«       Z
edddœd d„«       Zedddœd d„«       Z	 dddœ	 	 	 	 	 d!d„Z	 dddœ	 	 	 	 	 d!d„Zddœd"d„Zd#d„Zd#d„Zd$d„Zy)%ÚAsyncSoftReadWriteLockaÒ  
    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          	     ó€   — t        j                  «       | _        t        |||||||¬«      | _        || _        |	| _        y )N)r   r   r   r   r   )ÚosÚgetpidÚ_creator_pidr	   Ú_lockÚ_loopÚ	_executor)
ÚselfÚ	lock_fileÚtimeoutr   r   r   r   r   r   r   s
             úc/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/filelock/_soft_rw/_async.pyÚ__init__zAsyncSoftReadWriteLock.__init__,   sC   € ô ŸI™I›KˆÔÜ&ØØØØ%Ø1Ø+Ø'ô
ˆŒ
ð ˆŒ
Ø!ˆ�ó    c                ó.   — | j                   j                  S )z4The path to the lock file passed to the constructor.)r   r!   ©r    s    r#   r!   z AsyncSoftReadWriteLock.lock_fileF   s   € ð �z‰z×#Ñ#Ð#r%   c                ó.   — | j                   j                  S )z\The default timeout applied when ``acquire_read`` / ``acquire_write`` is called without one.)r   r"   r'   s    r#   r"   zAsyncSoftReadWriteLock.timeoutK   s   € ð �z‰z×!Ñ!Ð!r%   c                ó.   — | j                   j                  S )zYWhether ``acquire_*`` defaults to blocking; ``False`` makes contention raise immediately.)r   r   r'   s    r#   r   zAsyncSoftReadWriteLock.blockingP   s   € ð �z‰z×"Ñ"Ð"r%   c                ó   — | j                   S )zNThe event loop used for ``run_in_executor``, or ``None`` for the running loop.)r   r'   s    r#   r   zAsyncSoftReadWriteLock.loopU   s   € ð �z‰zÐr%   c                ó   — | j                   S )zPThe executor used for ``run_in_executor``, or ``None`` for the default executor.)r   r'   s    r#   r   zAsyncSoftReadWriteLock.executorZ   s   € ð �~‰~Ðr%   ©r   c              óÂ   K  — | j                  ||¬«      ƒ d{  –—†  	 d­–— | j                  «       ƒ d{  –—†  y7 Œ#7 Œ# | j                  «       ƒ d{  –—†7   w xY w­w)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_lockz AsyncSoftReadWriteLock.read_lock_   sR   è ø€ ð ×Ñ °(ÐÓ;×;Ð;ð	!Üà—,‘,“.× Ñ ð	 	<øð !ù�$—,‘,“.× Ò üó>   ‚A™=šAŸA ¤A·?¸A¿AÁAÁAÁAÁAc              óÂ   K  — | j                  ||¬«      ƒ d{  –—†  	 d­–— | j                  «       ƒ d{  –—†  y7 Œ#7 Œ# | j                  «       ƒ d{  –—†7   w xY w­w)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/   r0   s      r#   Ú
write_lockz!AsyncSoftReadWriteLock.write_lockq   sR   è ø€ ð × Ñ  °8Ð Ó<×<Ð<ð	!Üà—,‘,“.× Ñ ð	 	=øð !ù�$—,‘,“.× Ò ür2   c             ƒ  ó¦   K  — | j                  «        | j                  | j                  j                  ||¬«      ƒ d{  –—†  t	        | ¬«      S 7 Œ­w)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Ú_runr   r.   Ú$AsyncAcquireSoftReadWriteReturnProxyr0   s      r#   r.   z#AsyncSoftReadWriteLock.acquire_readƒ   sG   è ø€ ð& 	× Ñ Ô"Ø�i‰i˜Ÿ
™
×/Ñ/°À8ˆiÓL×LÐLÜ3¸Ô>Ð>ð 	Múó   ‚<A¾A¿Ac             ƒ  ó¦   K  — | j                  «        | j                  | j                  j                  ||¬«      ƒ d{  –—†  t	        | ¬«      S 7 Œ­w)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,   Nr7   )r9   r:   r   r4   r;   r0   s      r#   r4   z$AsyncSoftReadWriteLock.acquire_writeš   sG   è ø€ ð& 	× Ñ Ô"Ø�i‰i˜Ÿ
™
×0Ñ0°'ÀHˆiÓM×MÐMÜ3¸Ô>Ð>ð 	Núr<   F©Úforcec             ƒ  ó²   K  — | j                   t        j                  «       k(  r0| j                  | j                  j
                  |¬«      ƒ d{  –—†  yy7 Œ­w)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``

        r>   N)r   r   r   r:   r   r/   )r    r?   s     r#   r/   zAsyncSoftReadWriteLock.release±   sD   è ø€ ð ×Ñ¤§	¡	£Ò+Ø—)‘)˜DŸJ™J×.Ñ.°e�)Ó<×<Ñ<ð ,Ø<ús   ‚AAÁAÁAc              ƒ  ó®   K  — | j                   t        j                  «       k(  r.| j                  | j                  j
                  «      ƒ d{  –—†  yy7 Œ­w)zRRelease any held lock and release the underlying filesystem resources. Idempotent.N)r   r   r   r:   r   Úcloser'   s    r#   rB   zAsyncSoftReadWriteLock.close½   s>   è ø€ à×Ñ¤§	¡	£Ò+Ø—)‘)˜DŸJ™J×,Ñ,Ó-×-Ñ-ð ,Ø-ús   ‚A
AÁAÁAc                ó|   — | j                   t        j                  «       k7  rd| j                  › d�}t	        |«      ‚y )NzAsyncSoftReadWriteLock on z4 was inherited across fork; construct a new instance)r   r   r   r!   ÚRuntimeError)r    Úmsgs     r#   r9   z*AsyncSoftReadWriteLock._raise_if_inheritedÂ   s:   € Ø×Ñ¤§	¡	£Ò+Ø.¨t¯~©~Ð.>Ð>rÐsˆCÜ˜sÓ#Ð#ð ,r%   c              �  óÈ   K  — | j                   xs t        j                  «       }|j                  | j                  t        j                  |g|¢­i |¤Ž«      ƒ d {  –—† S 7 Œ­w©N)r   ÚasyncioÚget_running_loopÚrun_in_executorr   Ú	functoolsÚpartial)r    ÚfuncÚargsÚkwargsr   s        r#   r:   zAsyncSoftReadWriteLock._runÇ   sQ   è ø€ Ø�z‰zÒ7œW×5Ñ5Ó7ˆØ×)Ñ)¨$¯.©.¼)×:KÑ:KÈDÐ:bÐSWÒ:bÐ[aÑ:bÓc×cÐcÐcús   ‚AA"ÁA ÁA")éÿÿÿÿ)r!   zstr | os.PathLike[str]r"   Úfloatr   Úboolr   rR   r   rQ   r   úfloat | Noner   rQ   r   ú asyncio.AbstractEventLoop | Noner   úfutures.Executor | NoneÚreturnÚNone)rV   Ústr)rV   rQ   )rV   rR   )rV   rT   )rV   rU   rG   )r"   rS   r   úbool | NonerV   zAsyncGenerator[None])r"   rS   r   rY   rV   r;   )r?   rR   rV   rW   )rV   rW   )rM   zCallable[_P, _R]rN   z_P.argsrO   z	_P.kwargsrV   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   Úpropertyr!   r"   r   r   r   r   r1   r5   r.   r4   r/   rB   r9   r:   © r%   r#   r   r      s™  „ ñð0 ð"ð
 Ø!Ø$(Ø(,Ø#Ø15Ø,0ñ"à)ð"ð ð"ð
 ð"ð ð"ð "ð"ð &ð"ð ð"ð /ð"ð *ð"ð 
ó"ð4 ò$ó ð$ð ò"ó ð"ð ò#ó ð#ð òó ðð òó ðð ð!ÐW[ô !ó ð!ð" ð!ÐX\ô !ó ð!ð$ '+ð?ØGKñ?Ø#ð?Ø9Dð?à	-ó?ð0 '+ð?ØGKñ?Ø#ð?Ø9Dð?à	-ó?ð. .3õ 
=ó.ó
$ô
dr%   r   c                  ó8   — e Zd ZdZdd„Zdd„Z	 	 	 	 	 	 	 	 dd„Zy)	r;   zTAsync context-aware object that releases an :class:`AsyncSoftReadWriteLock` on exit.c                ó   — || _         y rG   r7   )r    r8   s     r#   r$   z-AsyncAcquireSoftReadWriteReturnProxy.__init__Ï   s	   € Øˆ�	r%   c              ƒ  ó"   K  — | j                   S ­wrG   r7   r'   s    r#   Ú
__aenter__z/AsyncAcquireSoftReadWriteReturnProxy.__aenter__Ò   s   è ø€ Ø�y‰yÐùs   ‚c              ƒ  óT   K  — | j                   j                  «       ƒ d {  –—†  y 7 Œ­wrG   )r8   r/   )r    Úexc_typeÚ	exc_valueÚ	tracebacks       r#   Ú	__aexit__z.AsyncAcquireSoftReadWriteReturnProxy.__aexit__Õ   s   è ø€ ð �i‰i×ÑÓ!×!Ò!ús   ‚( &¡(N)r8   r   rV   rW   )rV   r   )re   ztype[BaseException] | Nonerf   zBaseException | Nonerg   zTracebackType | NonerV   rW   )rZ   r[   r\   r]   r$   rc   rh   r_   r%   r#   r;   r;   Ì   s:   „ Ù^óóð"à,ð"ð (ð"ð (ð	"ð
 
ô"r%   r;   )r]   Ú
__future__r   rH   rK   r   Ú
contextlibr   Útypingr   r   r   Ú_syncr	   Úcollections.abcr
   r   Ú
concurrentr   Útypesr   r   r   r   r;   Ú__all__r_   r%   r#   ú<module>rq      sf   ðÙ Oå "ã Û Û 	Ý *ß 4Ñ 4å $áß8Ý"Ý#áˆtƒ_€ÙˆTƒ]€÷sdñ sd÷l"ñ "ð& +Øð�r%   