
    Kiw6                       S r SSKJr  SSKrSSKrSSK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JrJrJr  SS	KJrJrJrJr  SS
KJr  SSKJr  SSKJr  SSKJr  \(       a3  SSK r SSK!J"r"  SSK#J$r$  SSK%J&r&  \ RN                  S:  a  SSKJ(r(  OSSK)J(r(  \RT                  " S5      r+\	 " S S\5      5       r, " S S\,\5      r- " S S5      r. " S S\5      r/ " S S\\/S9r0 " S S \\05      r1 " S! S"\\05      r2 " S# S$\\05      r3/ S%Qr4g)&z1An asyncio-based implementation of the file lock.    )annotationsN)	dataclass)iscoroutinefunction)local)TYPE_CHECKINGAnyNoReturncast   )_UNSET_FILE_MODEBaseFileLockFileLockContextFileLockMeta)Timeout)SoftFileLock)UnixFileLock)WindowsFileLock)Callable)futures)TracebackType)      )Selffilelockc                  D    \ rS rSr% SrSrS\S'   SrS\S'   SrS	\S
'   Sr	g)AsyncFileLockContext$   zGA dataclass which holds the context for a ``BaseAsyncFileLock`` object.Tboolrun_in_executorNfutures.Executor | Noneexecutor asyncio.AbstractEventLoop | Noneloop )
__name__
__module____qualname____firstlineno____doc__r   __annotations__r!   r#   __static_attributes__r$       R/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/filelock/asyncio.pyr   r   $   s+    Q !OT  )-H%, .2D
*1r,   r   c                      \ rS rSrSrSrg)AsyncThreadLocalFileContext2   z8A thread local version of the ``FileLockContext`` class.r$   Nr%   r&   r'   r(   r)   r+   r$   r,   r-   r/   r/   2   s    Br,   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)AsyncAcquireReturnProxy6   zDA context-aware object that will release the lock file when exiting.c                    Xl         g Nlock)selfr8   s     r-   __init__ AsyncAcquireReturnProxy.__init__9   s    	r,   c                "   #    U R                   $ 7fr6   r7   r9   s    r-   
__aenter__"AsyncAcquireReturnProxy.__aenter__<   s     yys   c                T   #    U R                   R                  5       I S h  vN   g  N7fr6   )r8   releaser9   exc_type	exc_value	tracebacks       r-   	__aexit__!AsyncAcquireReturnProxy.__aexit__?   s      ii!!!s   (&(r7   N)r8   BaseAsyncFileLockreturnNone)rI   rH   rC   ztype[BaseException] | NonerD   zBaseException | NonerE   zTracebackType | NonerI   rJ   )	r%   r&   r'   r(   r)   r:   r>   rF   r+   r$   r,   r-   r3   r3   6   s:    N"," (" (	"
 
"r,   r3   c            	      x   ^  \ rS rSrS\S4SSSSSSSS.                       S
U 4S jjjjrS	rU =r$ )AsyncFileLockMetaH   FT皙?Nblockingis_singletonpoll_intervallifetimer#   r   r!   c                  > U(       a  U
(       a  Sn[        U5      e[        TU ]	  UUUUUUUUU	U
US9n[        SU5      $ )Nz:run_in_executor is not supported when thread_local is True)	lock_filetimeoutmodethread_localrR   rS   rT   rU   r#   r   r!   rH   )
ValueErrorsuper__call__r
   )clsrW   rX   rY   rZ   rR   rS   rT   rU   r#   r   r!   msginstance	__class__s                 r-   r]   AsyncFileLockMeta.__call__I   s^     ONCS/!7#%%'+ $ 
 '22r,   r$   )rW   str | os.PathLike[str]rX   floatrY   intrZ   r   rR   r   rS   r   rT   rd   rU   float | Noner#   r"   r   r   r!   r    rI   rH   )r%   r&   r'   r(   r   r]   r+   __classcell__)ra   s   @r-   rM   rM   H   s     $"3 "#!%15 $,03)3 3 	3
 3 3 3 3 3 /3 3 *3 
3 3r,   rM   c            	      P   \ rS rSrSrS\S4SSSSSSSS.                       SS	 jjjr\SS
 j5       r\SS j5       r	\	R                  SS j5       r	\SS j5       r  SSSS.         SS jjjr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)%rH   k   zD
Base class for asynchronous file locks.

.. versionadded:: 3.15.0

rO   FTrP   NrQ   c          
         X@l         X`l        [        R                  " U5      UUUUUU	U
US.	nU(       a  [        O[
        " S0 UD6U l        g)a  
Create a new lock object.

:param lock_file: path to the file
:param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in the
    acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it to a
    negative value. A timeout of 0 means that there is exactly one attempt to acquire the file lock.
:param mode: file permissions for the lockfile. When not specified, the OS controls permissions via umask and
    default ACLs, preserving POSIX default ACL inheritance in shared directories.
:param thread_local: Whether this object's internal context should be thread local or not. If this is set to
    ``False`` then the lock will be reentrant across threads.
:param blocking: whether the lock should be blocking or not
:param is_singleton: If this is set to ``True`` then only one instance of this class will be created per lock
    file. This is useful if you want to use the lock object for reentrant locking without needing to pass the
    same object around.
:param poll_interval: default interval for polling the lock file, in seconds. It will be used as fallback value
    in the acquire method, if no poll_interval value (``None``) is given.
:param lifetime: maximum time in seconds a lock can be held before it is considered expired. When set, a waiting
    process will break a lock whose file modification time is older than ``lifetime`` seconds. ``None`` (the
    default) means locks never expire.
:param loop: The event loop to use. If not specified, the running event loop will be used.
:param run_in_executor: If this is set to ``True`` then the lock will be acquired in an executor.
:param executor: The executor to use. If not specified, the default executor will be used.

)	rW   rX   rY   rR   rT   rU   r#   r   r!   Nr$   )_is_thread_local_is_singletonosfspathr/   r   _context)r9   rW   rX   rY   rZ   rR   rS   rT   rU   r#   r   r!   kwargss                r-   r:   BaseAsyncFileLock.__init__s   s_    P !-)
 9- * . 
"
 O[/J`t/t /
/
r,   c                .    U R                   R                  $ )z":returns: whether run in executor.)ro   r   r=   s    r-   r   !BaseAsyncFileLock.run_in_executor   s     }},,,r,   c                .    U R                   R                  $ )z:returns: the executor.ro   r!   r=   s    r-   r!   BaseAsyncFileLock.executor   s     }}%%%r,   c                $    XR                   l        g)z[
Change the executor.

:param futures.Executor | None value: the new executor or ``None``

Nru   )r9   values     r-   r!   rv      s     "'r,   c                .    U R                   R                  $ )z:returns: the event loop.)ro   r#   r=   s    r-   r#   BaseAsyncFileLock.loop   s     }}!!!r,   )rR   cancel_checkc          	       #    Uc  U R                   R                  nUc  U R                   R                  nUc  U R                   R                  nU R                   =R                  S-  sl        [        U 5      nU R                  n[        R                  " 5       n  U R                  (       dI  U R                  5         [        R                  SXV5        U R                  U R                  5      I Sh  vN   U R                  (       a  [        R                  SXV5        O\U R                  UUUUUUS9(       a  [!        U5      eSn[        R                  XXb5        ["        R$                  " U5      I Sh  vN   M  [+        U S9$  N N! [&         a4    [)        SU R                   R                  S-
  5      U R                   l        e f = f7f)	a  
Try to acquire the file lock.

:param timeout: maximum wait time for acquiring the lock, ``None`` means use the default
    :attr:`~BaseFileLock.timeout` is and if ``timeout < 0``, there is no timeout and this method will block
    until the lock could be acquired
:param poll_interval: interval of trying to acquire the lock file, ``None`` means use the default
    :attr:`~BaseFileLock.poll_interval`
:param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
    first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
:param cancel_check: a callable returning ``True`` when the acquisition should be canceled. Checked on each poll
    iteration. When triggered, raises :class:`~Timeout` just like an expired timeout.

:returns: a context object that will unlock the file when the context is exited

:raises Timeout: if fails to acquire lock within the timeout period

.. code-block:: python

    # You can use this method in the context manager (recommended)
    with lock.acquire():
        pass

    # Or use an equivalent try-finally construct:
    lock.acquire()
    try:
        pass
    finally:
        lock.release()

Nr   z#Attempting to acquire lock %s on %szLock %s acquired on %s)rR   r{   rX   
start_timez2Lock %s not acquired on %s, waiting %s seconds ...r   r7   )ro   rX   rR   rT   lock_counteridrW   timeperf_counter	is_locked_try_break_expired_lock_LOGGERdebug_run_internal_method_acquire_check_give_upr   asynciosleepBaseExceptionmaxr3   )	r9   rX   rT   rR   r{   lock_idlock_filenamer}   r_   s	            r-   acquireBaseAsyncFileLock.acquire   s    P ?mm++G}}--H  MM77M 	""a'"T(&&(
	~~002MM"G`33DMMBBB>>MM":GS&&!%!-#) '  "-00JcMImmM222' . 'D11' C 3 	),Q0J0JQ0N)ODMM&	sP   BGAF 0F1+F GAF 2F3F 9	GF F >GGc                  #    U R                   (       a  U R                  =R                  S-  sl        U R                  R                  S:X  d  U(       aw  [        U 5      U R                  p2[
        R                  SX#5        U R                  U R                  5      I Sh  vN   SU R                  l        [
        R                  SX#5        ggg N.7f)z
Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file
itself is not automatically deleted.

:param force: If true, the lock counter is ignored and the lock is released in every case.

r   r   z#Attempting to release lock %s on %sNzLock %s released on %s)	r   ro   r~   r   rW   r   r   r   _release)r9   forcer   r   s       r-   rA   BaseAsyncFileLock.release  s      >>MM&&!+&}}))Q.%)+D4>>CW\//>>>-.*6O 38  ?s   BCC/Cc                  #    [        U5      (       a  U" 5       I S h  vN   g U R                  (       aM  U R                  =(       d    [        R                  " 5       nUR                  U R
                  U5      I S h  vN   g U" 5         g  Nk N7fr6   )r   r   r#   r   get_running_loopr!   )r9   methodr#   s      r-   r   &BaseAsyncFileLock._run_internal_method,  sb     v&&(NN!!99: 8 8 :D&&t}}f===H  >s"   BB	AB;B<BBc                    Sn[        U5      e)z
Replace old __enter__ method to avoid using it.

NOTE: DO NOT USE `with` FOR ASYNCIO LOCKS, USE `async with` INSTEAD.

:returns: none
:rtype: NoReturn

z>Do not use `with` for asyncio locks, use `async with` instead.)NotImplementedError)r9   r_   s     r-   	__enter__BaseAsyncFileLock.__enter__5  s     O!#&&r,   c                B   #    U R                  5       I Sh  vN   U $  N7f)z/
Acquire the lock.

:returns: the lock object

N)r   r=   s    r-   r>   BaseAsyncFileLock.__aenter__B  s       lln 	s   c                @   #    U R                  5       I Sh  vN   g N7f)z
Release the lock.

:param exc_type: the exception type if raised
:param exc_value: the exception value if raised
:param traceback: the exception traceback if raised

N)rA   rB   s       r-   rF   BaseAsyncFileLock.__aexit__L  s      llns   c                `   [         R                  " [        5         U R                  =(       d    [        R
                  " 5       nUR                  5       (       d  UR                  U R                  SS95        OUR                  U R                  SS95        SSS5        g! , (       d  f       g= f)z'Called when the lock object is deleted.T)r   N)

contextlibsuppressRuntimeErrorr#   r   r   
is_runningrun_until_completerA   create_task)r9   r#   s     r-   __del__BaseAsyncFileLock.__del__\  sr      .99: 8 8 :D??$$''4(@A  D!9: /..s   A;B
B-)ro   rl   rk   )rW   rc   rX   rd   rY   re   rZ   r   rR   r   rS   r   rT   rd   rU   rf   r#   r"   r   r   r!   r    rI   rJ   )rI   r   )rI   r    )rx   r    rI   rJ   )rI   r"   )NN)
rX   rf   rT   rf   rR   zbool | Noner{   zCallable[[], bool] | NonerI   r3   )F)r   r   rI   rJ   )r   zCallable[[], Any]rI   rJ   )rI   r	   )rI   r   rK   )rI   rJ   )r%   r&   r'   r(   r)   r   r:   propertyr   r!   setterr#   r   rA   r   r   r>   rF   r   r+   r$   r,   r-   rH   rH   k   s    $":
 "#!%15 $,0:
):
 :
 	:

 :
 :
 :
 :
 :
 /:
 :
 *:
 
:
x - - & & __' ' " " !%&*O2
 !%26O2O2 $O2
 O2 0O2 
!O2bP&', ( (	
 
 ;r,   rH   )	metaclassc                      \ rS rSrSrSrg)AsyncSoftFileLockif  z.Simply watches the existence of the lock file.r$   Nr1   r$   r,   r-   r   r   f  s    8r,   r   c                      \ rS rSrSrSrg)AsyncUnixFileLockij  zHUses the :func:`fcntl.flock` to hard lock the lock file on unix systems.r$   Nr1   r$   r,   r-   r   r   j  s    Rr,   r   c                      \ rS rSrSrSrg)AsyncWindowsFileLockin  zNUses the :func:`msvcrt.locking` to hard lock the lock file on windows systems.r$   Nr1   r$   r,   r-   r   r   n  s    Xr,   r   )r3   r   r   r   rH   )5r)   
__future__r   r   r   loggingrm   r   dataclassesr   inspectr   	threadingr   typingr   r   r	   r
   _apir   r   r   r   _errorr   _softr   _unixr   _windowsr   syscollections.abcr   
concurrentr   typesr   version_infor   typing_extensions	getLoggerr   r   r/   r3   rM   rH   r   r   r   __all__r$   r,   r-   <module>r      s    7 "    	  ! '  5 5 O O    %("#
7"* 

J
' 
2? 
2 
2C"6 C" "$ 3  3Fx;0A x;v9&7 9S&7 SY?,= Yr,   