§
    ÏŽ°iy  ã                  óº   — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
 erddlZddlmZmZ dd	lmZ dd
lmZ  G d„ d¦  «        Z G d„ d¦  «        ZddgZdS )zEAsync wrapper around :class:`ReadWriteLock` for use with ``asyncio``.é    )ÚannotationsN)Úasynccontextmanager)ÚTYPE_CHECKINGé   )ÚReadWriteLock)ÚAsyncGeneratorÚCallable)Úfutures)ÚTracebackTypec                  ó*   — e Zd ZdZdd„Zdd„Zdd„ZdS )Ú AsyncAcquireReadWriteReturnProxyzEContext-aware object that releases the async read/write lock on exit.ÚlockÚAsyncReadWriteLockÚreturnÚNonec                ó   — || _         d S ©N©r   )Úselfr   s     úM/var/www/icac/venv/lib/python3.11/site-packages/filelock/_async_read_write.pyÚ__init__z)AsyncAcquireReadWriteReturnProxy.__init__   s   € ØˆŒ	ˆ	ˆ	ó    c              ƒ  ó   K  — | j         S r   r   ©r   s    r   Ú
__aenter__z+AsyncAcquireReadWriteReturnProxy.__aenter__   s   è è € ØŒyÐr   Úexc_typeútype[BaseException] | NoneÚ	exc_valueúBaseException | NoneÚ	tracebackúTracebackType | Nonec              ƒ  óH   K  — | j                              ¦   «         ƒ d {V —† d S r   )r   Úrelease)r   r   r   r    s       r   Ú	__aexit__z*AsyncAcquireReadWriteReturnProxy.__aexit__   s4   è è € ð Œi×ÒÑ!Ô!Ð!Ð!Ð!Ð!Ð!Ð!Ð!Ð!Ð!r   N)r   r   r   r   )r   r   )r   r   r   r   r    r!   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r$   © r   r   r   r      sV   € € € € € ØOÐOðð ð ð ðð ð ð ð"ð "ð "ð "ð "ð "r   r   c                  ó   — e Zd ZdZ	 d.dddddœd/d„Zed0d„¦   «         Zed1d„¦   «         Zed2d„¦   «         Zed3d„¦   «         Z	ed4d„¦   «         Z
d5d„Zd.dd œd6d"„Zd.dd œd6d#„Zd$d%œd7d'„Zed8dd œd9d+„¦   «         Zed8dd œd9d,„¦   «         Zd:d-„ZdS );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ÚexecutorÚ	lock_fileústr | os.PathLike[str]ÚtimeoutÚfloatr,   Úboolr-   r.   ú asyncio.AbstractEventLoop | Noner/   úfutures.Executor | Noner   r   c               óR   — t          ||||¬¦  «        | _        || _        || _        d S )N)r,   r-   )r   Ú_lockÚ_loopÚ	_executor)r   r0   r2   r,   r-   r.   r/   s          r   r   zAsyncReadWriteLock.__init__8   s/   € õ # 9¨gÀÐWcÐdÑdÔdˆŒ
ØˆŒ
Ø!ˆŒˆˆr   Ústrc                ó   — | j         j        S )z$:returns: the path to the lock file.)r8   r0   r   s    r   r0   zAsyncReadWriteLock.lock_fileF   s   € ð ŒzÔ#Ð#r   c                ó   — | j         j        S )z:returns: the default timeout.)r8   r2   r   s    r   r2   zAsyncReadWriteLock.timeoutK   s   € ð ŒzÔ!Ð!r   c                ó   — | j         j        S )z1:returns: whether blocking is enabled by default.)r8   r,   r   s    r   r,   zAsyncReadWriteLock.blockingP   s   € ð ŒzÔ"Ð"r   c                ó   — | j         S )z<:returns: the event loop (or ``None`` for the running loop).)r9   r   s    r   r.   zAsyncReadWriteLock.loopU   s   € ð ŒzÐr   c                ó   — | j         S )z5:returns: the executor (or ``None`` for the default).)r:   r   s    r   r/   zAsyncReadWriteLock.executorZ   s   € ð Œ~Ðr   ÚfuncúCallable[..., object]ÚargsÚobjectÚkwargsc                ó¢   K  — | j         pt          j        ¦   «         }|                     | j        t          j        |g|¢R i |¤Ž¦  «        ƒ d {V —†S r   )r9   ÚasyncioÚget_running_loopÚrun_in_executorr:   Ú	functoolsÚpartial)r   rA   rC   rE   r.   s        r   Ú_runzAsyncReadWriteLock._run_   sb   è è € ØŒzÐ7WÔ5Ñ7Ô7ˆØ×)Ò)¨$¬.½)Ô:KÈDÐ:bÐSWÐ:bÐ:bÐ:bÐ[aÐ:bÐ:bÑcÔcÐcÐcÐcÐcÐcÐcÐcr   ©r,   r   c             ƒ  óv   K  — |                       | j        j        ||¬¦  «        ƒ d{V —† t          | ¬¦  «        S )a7  
        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

        rM   Nr   )rL   r8   Úacquire_readr   ©r   r2   r,   s      r   rO   zAsyncReadWriteLock.acquire_readc   sH   è è € ð iŠi˜œ
Ô/°À8ˆiÑLÔLÐLÐLÐLÐLÐLÐLÐLÝ/°TÐ:Ñ:Ô:Ð:r   c             ƒ  óv   K  — |                       | j        j        ||¬¦  «        ƒ d{V —† t          | ¬¦  «        S )aZ  
        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

        rM   Nr   )rL   r8   Úacquire_writer   rP   s      r   rR   z AsyncReadWriteLock.acquire_writeu   sH   è è € ð iŠi˜œ
Ô0°'ÀHˆiÑMÔMÐMÐMÐMÐMÐMÐMÐMÝ/°TÐ:Ñ:Ô:Ð:r   F©ÚforcerT   c             ƒ  óX   K  — |                       | j        j        |¬¦  «        ƒ d{V —† dS )a2  
        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``

        rS   N)rL   r8   r#   )r   rT   s     r   r#   zAsyncReadWriteLock.release‡   s;   è è € ð iŠi˜œ
Ô*°%ˆiÑ8Ô8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8r   úfloat | Noneúbool | NoneúAsyncGenerator[None]c              óú   K  — |€| j         j        }|€| j         j        }|                      ||¬¦  «        ƒ d{V —† 	 dW V — |                      ¦   «         ƒ d{V —† dS # |                      ¦   «         ƒ d{V —† w xY w)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

        NrM   )r8   r2   r,   rO   r#   rP   s      r   Ú	read_lockzAsyncReadWriteLock.read_lock”   s®   è è € ð ˆ?Ø”jÔ(ˆGØÐØ”zÔ*ˆHØ×Ò °(ÐÑ;Ô;Ð;Ð;Ð;Ð;Ð;Ð;Ð;ð	!ØˆEˆEˆEˆEà—,’,‘.”.Ð Ð Ð Ð Ð Ð Ð Ð Ð ø$—,’,‘.”.Ð Ð Ð Ð Ð Ð Ð Ð øøøó   ½A ÁA:c              óú   K  — |€| j         j        }|€| j         j        }|                      ||¬¦  «        ƒ d{V —† 	 dW V — |                      ¦   «         ƒ d{V —† dS # |                      ¦   «         ƒ d{V —† w xY w)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

        NrM   )r8   r2   r,   rR   r#   rP   s      r   Ú
write_lockzAsyncReadWriteLock.write_lock©   s®   è è € ð ˆ?Ø”jÔ(ˆGØÐØ”zÔ*ˆHØ× Ò  °8Ð Ñ<Ô<Ð<Ð<Ð<Ð<Ð<Ð<Ð<ð	!ØˆEˆEˆEˆEà—,’,‘.”.Ð Ð Ð Ð Ð Ð Ð Ð Ð ø$—,’,‘.”.Ð Ð Ð Ð Ð Ð Ð Ð øøør[   c              ƒ  óT   K  — |                       | j        j        ¦  «        ƒ d{V —† dS )z¤
        Release the lock (if held) and close the underlying SQLite connection.

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

        N)rL   r8   Úcloser   s    r   r_   zAsyncReadWriteLock.close¾   s7   è è € ð iŠi˜œ
Ô(Ñ)Ô)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)r   )r+   )r0   r1   r2   r3   r,   r4   r-   r4   r.   r5   r/   r6   r   r   )r   r;   )r   r3   )r   r4   )r   r5   )r   r6   )rA   rB   rC   rD   rE   rD   r   rD   )r2   r3   r,   r4   r   r   )rT   r4   r   r   r   )r2   rV   r,   rW   r   rX   )r   r   )r%   r&   r'   r(   r   Úpropertyr0   r2   r,   r.   r/   rL   rO   rR   r#   r   rZ   r]   r_   r)   r   r   r   r   %   só  € € € € € ðð ð* ð"ð
 Ø!Ø15Ø,0ð"ð "ð "ð "ð "ð "ð ð$ð $ð $ñ „Xð$ð ð"ð "ð "ñ „Xð"ð ð#ð #ð #ñ „Xð#ð ðð ð ñ „Xðð ðð ð ñ „Xððdð dð dð dð;È$ð ;ð ;ð ;ð ;ð ;ð ;ð$;È4ð ;ð ;ð ;ð ;ð ;ð ;ð$ .3ð 9ð 9ð 9ð 9ð 9ð 9ð ð!ÐW[ð !ð !ð !ð !ð !ñ Ôð!ð( ð!ÐX\ð !ð !ð !ð !ð !ñ Ôð!ð(*ð *ð *ð *ð *ð *r   r   )r(   Ú
__future__r   rG   rJ   Ú
contextlibr   Útypingr   Ú_read_writer   ÚosÚcollections.abcr   r	   Ú
concurrentr
   Útypesr   r   r   Ú__all__r)   r   r   ú<module>rj      s!  ðØ KÐ Kà "Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ø  Ð  Ð  Ð  Ð  Ð  à &Ð &Ð &Ð &Ð &Ð &àð $Ø€I€I€IØ8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ø"Ð"Ð"Ð"Ð"Ð"Ø#Ð#Ð#Ð#Ð#Ð#ð"ð "ð "ð "ð "ñ "ô "ð "ð$`*ð `*ð `*ð `*ð `*ñ `*ô `*ð `*ðH 'Øð€€€r   