
    Loj'                        % 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Jr  SS	KJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$  SS
K%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-  SSK.J/r/  SSK0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9  \(       a9  SSK:r:SSK;J<r<J=r=J>r>J?r?  SSK@JArA  SSKBJCrC  \:R                  S:  a  SSKJErE  OSSKFJErE  \R                  " S5      rHS\IS'   SrJS\IS'   SrKS\IS'   SrLS\IS'   / rMS \IS!'   \" S"S#S$9rN " S% S&\5      rO " S' S#\\OS(9rP\	 " S) S*\5      5       rQ " S+ S,\Q\5      rR " S- S.5      rS " S/ S0\3\P5      rT " S1 S2\5\P5      rU " S3 S4\1\P5      rV " S5 S6\7\P5      rW " S7 S8\9\P5      rX/ S9QrYg):z1An asyncio-based implementation of the file lock.    )annotationsN)	dataclass)iscoroutinefunction)local)TYPE_CHECKINGFinalNoReturnTypeVarcast   )_UNSET_FILE_MODEBaseFileLockCloseErrorPolicyContextErrorPolicyFileLockContextFileLockMeta_append_exception_context
_canonical_ExtraValue_fork_transition_grouped_errors_raise_body_and_release_raise_chained_errors_raise_cleanup_errors_raise_grouped_errors_register_fork_object)_AsyncTransitionGate _AsyncTransitionUnavailableError_BackendOutcome_capture_awaitable_capture_call_drain_future_future_result_wait_until_done)Timeout)SoftFileLease)SoftFileLock)StrictSoftFileLock)UnixFileLock)WindowsFileLock)	AwaitableCallable	CoroutineHashable)futures)TracebackType)      )SelffilelockzFinal[logging.Logger]_LOGGERz9lock release cancellation and backend release both failedz
Final[str]"_ASYNC_RELEASE_CANCELLATION_ERRORSz>context body, release cancellation, and backend release failed_ASYNC_CONTEXT_RELEASE_ERRORS$_filelock_async_release_cancellation'_ASYNC_RELEASE_CANCELLATION_MARKER_ATTRzFinal[list[None]]"_ASYNC_RELEASE_CANCELLATION_MARKER_ATBaseAsyncFileLock)boundc                     ^  \ rS rSrS\S4SSSSSSSSSSSSS	.                                     SU 4S
 jjjjrSrU =r$ )AsyncFileLockMetaG   FT皙?Nchaindefaultblockingis_singletonpoll_intervallifetimecontext_error_policyclose_error_policyfallback_to_softpreserve_lock_fileon_acquiredlooprun_in_executorexecutorc                  > U(       a  U(       a  Sn[        U5      e[        TU ]  " S0 UD0 SU_SU_SU_SU_SU_SU_SU_S	U_S
U	_SU
_SU_SU_SU_SU_SU_SU_D6$ )Nz:run_in_executor is not supported when thread_local is True	lock_filetimeoutmodethread_localrF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ    )
ValueErrorsuper__call__)clsrS   rT   rU   rV   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   kwargsmsg	__class__s                      J/mnt/workspace/venv-train/lib/python3.13/site-packages/filelock/asyncio.pyrZ   AsyncFileLockMeta.__call__H   s    * ONCS/!w 


 
 	

 &
 
 &
 (
 
 "6
  2
 .
  2
 $
 
  ,!
" #
 	
    rW   )&r[   z	type[_AT]rS   str | os.PathLike[str]rT   floatrU   intrV   boolrF   re   rG   re   rH   rc   rI   float | NonerJ   r   rK   r   rL   re   rM   re   rN   Callable[[int], None] | NonerO    asyncio.AbstractEventLoop | NonerP   re   rQ   futures.Executor | Noner\   r   returnr;   )__name__
__module____qualname____firstlineno__r   rZ   __static_attributes____classcell__)r^   s   @r_   r?   r?   G   s     $"*
 "#!%3:/8!%#(4815 $,0%*
*
)*
 *
 	*

 *
 *
 *
 *
 *
 1*
 -*
 *
 !*
 2*
  /!*
" #*
$ *%*
& '*
( 
)*
 *
ra   r?   c                     \ rS rSr% SrSrS\S'   SrS\S'   \S0S	 j5       r	S
\
S4SSSSSSSSSSSSS.                                 S1S jjjr\S2S j5       r\S3S j5       r\R                  S4S j5       r\S5S j5       r  S6SSS.         S7S jjjr            S8S jr            S9S jrS:S jrS;S jrS<S jr S=         S>S jjrS?S@S jjrS@S  jrS:S! jr    SAS" jrSBS# jrS:S$ jrSCS% jrSDS& jrS:S' jr S:S( jr!SES) jr"        SFS* jr#SGS+ jr$        SFS, jr%    SHS- jr&S:S. jr'S/r(g)Ir<   u   zD
Base class for asynchronous file locks.

.. versionadded:: 3.15.0

z'BaseAsyncFileLock instance in this taskstr_deadlock_holder_desc   rd   (_constructor_lifetime_warning_stacklevelc                 ,    [         R                  " 5       $ N)asynciocurrent_taskrW   ra   r_   _deadlock_scope!BaseAsyncFileLock._deadlock_scope   s     ##%%ra   rA   FTrB   NrC   rD   rE   c               0   [         R                  " 5       U l        X@l        X`l        Xl        Xl        Xl        Xl        Xl	        [        5       U l        U(       a  [        O[        " [         R                  " U5      UUUUUUUUS9	U l        [!        U 5        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. When ``True`` (the default), **all fields of the
    lock's internal context are per-thread**, including the configuration values ``poll_interval``, ``timeout``,
    ``blocking``, ``mode``, and ``lifetime``. Setting one of these properties from one thread does not change
    the value seen by another thread; threads that did not perform the write continue to see the value supplied
    at construction time. If you need configuration values to be visible across threads, construct the lock
    with ``thread_local=False``.
: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: for :class:`AsyncSoftFileLock`, the age in seconds after which a waiting process may delete
    the marker, even while its holder remains alive. This legacy expiry mode does not provide strict mutual
    exclusion. ``None`` (the default) disables age-based expiry. Native OS locks (:class:`AsyncFileLock`)
    cannot be revoked by file age and ignore a non-``None`` ``lifetime`` with a warning.
:param context_error_policy: how a context manager reconciles a failure in its body with a failure while
    releasing on exit. ``"chain"`` (the default) keeps Python's behavior: the release error propagates with the
    body error in its ``__context__``. ``"group"`` raises a :class:`BaseExceptionGroup` holding the body error
    first and the release error second, so neither hides the other.
:param close_error_policy: for native locks (:class:`AsyncFileLock`), what to do with an ``os.close`` failure
    after the OS unlock has already committed. ``"default"`` keeps each platform's historical behavior,
    ``"raise"`` always propagates the ``OSError``, and ``"suppress"`` always ignores it.
:param fallback_to_soft: for :class:`AsyncFileLock`, whether to fall back to soft existence locking when
    ``flock`` returns ``ENOSYS``. ``True`` (default) keeps the fallback; ``False`` propagates the error.
:param preserve_lock_file: for native locks (:class:`AsyncFileLock`), whether filelock promises not to unlink
    the lock pathname on release. ``False`` (default) keeps each backend's cleanup; ``True`` keeps a stable file
    identity (Windows skips its unlink, Unix refuses the ``ENOSYS`` soft fallback). :class:`AsyncSoftFileLock`
    rejects ``True``.
:param on_acquired: for native locks (:class:`AsyncFileLock`), a callable invoked with the borrowed lock
    descriptor once per physical acquisition, after the lock is held but before
    :meth:`~BaseAsyncFileLock.acquire` returns. With ``run_in_executor=True`` (the default) it runs in the
    backend executor. It must not close or unlock the descriptor; a raise rolls the acquisition back.
    :class:`AsyncSoftFileLock` rejects it.
: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.

)	rS   rT   rU   rF   rH   rI   rO   rP   rQ   N)osgetpid_creator_pid_is_thread_local_is_singleton_context_error_policy_close_error_policy_fallback_to_soft_preserve_lock_file_on_acquiredr   _transition_gateAsyncThreadLocalFileContextAsyncFileLockContextfspath_contextr   )selfrS   rT   rU   rV   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   s                    r_   __init__BaseAsyncFileLock.__init__   s    J IIK ,)%9"#5 !1#5 '=Q=SNZ/J`t/tii	*'+
/
 	d#ra   c                .    U R                   R                  $ )zWhether run in executor.)r   rP   r   s    r_   rP   !BaseAsyncFileLock.run_in_executor   s     }},,,ra   c                .    U R                   R                  $ )zThe executor.r   rQ   r   s    r_   rQ   BaseAsyncFileLock.executor   s     }}%%%ra   c                $    XR                   l        g)z[
Change the executor.

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

Nr   )r   values     r_   rQ   r      s     "'ra   c                .    U R                   R                  $ )zThe event loop.)r   rO   r   s    r_   rO   BaseAsyncFileLock.loop   s     }}!!!ra   )rF   cancel_checkc               n  #    U R                  5         Uc  U R                  R                  nUc  U R                  R                  nUc  U R                  R                  n[
        R                  " 5       n U R                  UUUUUS9I Sh  vN $  N! [         a    [        U R                  5      S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()

NrF   r   rT   rH   
start_time)_raise_if_inheritedr   rT   rF   rH   timeperf_counter_acquire_with_admissionr   r%   rS   )r   rT   rH   rF   r   r   s         r_   acquireBaseAsyncFileLock.acquire   s     N 	  "?mm++G}}--H  MM77M&&(
		455!)+% 6     0 	4$..)t3	4s0   A1B54B 
BB B5B !B22B5c          	     n  #    U R                   R                  UUUS:  a  S OXS-   US9 IS h  vN   [        U R                  5      nU R                  =R
                  S-  sl        U R                  XcUS9  X`R                  l         U R                  UUUUUS9I S h  vN    S U R                  l        U R                  U5        [        U S9sS S S 5      IS h  vN   $  N NC! [         a    U R                  U5        e f = f! S U R                  l        f = f N?! , IS h  vN  (       d  f       g = f7f)Nr   )rF   r   deadlinerH   r   )rT   rF   r   lock)r   hold_for_acquirer   rS   r   lock_counter_raise_if_would_deadlock
claim_root_async_poll_until_acquiredBaseException_reconcile_failed_acquire_commit_acquireAsyncAcquireReturnProxy)r   rF   r   rT   rH   r   	canonicals          r_   r   )BaseAsyncFileLock._acquire_with_admission:  s,     ((99%$q[Tj.B'	 : 
 
 #4>>2IMM&&!+&)))x)X'0MM$055%!-#"/) 6    ,0(  +*53
 
 
 ! ..y9 ,0(/
 
 
 
s{   +D5CD5ADC#C!C##*DD5DD5!C##D  DDDD5D2!D$"D2.D5c               "  #    [        U 5      nU R                  n U R                  5         U R                  (       dN  U R	                  5         [
        R                  SXg5        U R                  5       I S h  vN   U R                  5         U R                  (       a  [
        R                  SXg5        g U R                  UUUUS9(       a  [        U5      e[
        R                  SXgU5        [        R                  " U5      I S h  vN   M   N N7f)Nz#Attempting to acquire lock %s on %szLock %s acquired on %s)rF   r   rT   r   z2Lock %s not acquired on %s, waiting %s seconds ...)idrS   r   	is_locked_try_break_expired_lockr5   debug_run_acquire_attempt_check_give_upr%   ry   sleep)r   rF   r   rT   rH   r   lock_idlock_filenames           r_   r   ,BaseAsyncFileLock._async_poll_until_acquired^  s      T($$&>>,,.CW\//111((*~~6O""!)%	 #  m,,MMNPWhuv--...% 
 2 /s%   A3D5D6BDDDDc                  #    U R                  [        U R                  5      (       a  U R                  OU R                  5      n [        U5      I S h  vN    [        U5        g  N! [        R                   a  nS n [        U5      I S h  vN    O! [         a  nUn S nAOS nAff = fS nU R                  (       a=   [        U R                  5       5      I S h  vN    O! [         a  nUn S nAOS nAff = fUb)  Ub  U R                  SUUU5        U R                  SX#5        Ub  U R                  SX%5        e S nAff = f! [        R                   a$  nU R                  U5      I S h  vN     S nAg S nAff = f7f)NzClock acquisition cancellation, backend attempt, and rollback failedz=lock acquisition cancellation and backend attempt both failedz6lock acquisition cancellation and rollback both failed)_start_internal_methodr   _acquire!_acquire_with_fork_tracking_async_acquire_with_fork_trackingr$   ry   CancelledErrorr"   r   r   _start_tracked_release_raise_cancelled_errorsr#   #_rollback_backend_cancelled_acquire)r   acquire_futurecancellationacquire_errorerrorrollback_errors         r_   r   &BaseAsyncFileLock._run_acquire_attempt}  sl    44"4==11 2211

	">222>	J>*A 3%% 	26M&#N333  & %& 48N~~+'(C(C(EFFF$ +%*N+ (!-00]$%&	 ,,SUa ),,Ll ;	@ %% 	J::=III	Js   AFA' A%A' E $F%A' 'E;D>>BBBD>
B)B$D>$B))D> C#CC#"D>#
C9-C4/D>4C99AD>>EFE>E9.E1/E94F9E>>Fc                   #    U R                   (       a$   [        U R                  5       5      I S h  vN   UeUe N! [         a  nU R	                  X5         S nAUeS nAff = f7frx   )r   r"   r   r   _raise_acquire_rollback_errorsr   r   r   s      r_   r   5BaseAsyncFileLock._rollback_backend_cancelled_acquire  sd     >>S#D$?$?$ABBB m C  S33MRRSs7   A%< :< A%< 
A"AA%A""A%c                R    U R                   S:X  a  [        SX5        [        X5        g )Ngroupz1lock acquisition backend and rollback both failed)r   r   r   r   s      r_   r   0BaseAsyncFileLock._raise_acquire_rollback_errors  s$    %%0!"UWdum<ra   c                   U R                   S:X  a0  U[        :X  a  [        [        4OS nUc
  [	        XX5S9  [	        XX4US9  UR
                  =nb$  XbLa   UR
                  =nb  [        Xg5        Xbl        X#l        [        X45        g )Nr   )marker)r   r6   r9   r:   r   __context__r   r   )r   messager   first_errorsecond_errorr   contextcancellation_contexts           r_   r   )BaseAsyncFileLock._raise_cancelled_errors  s     %%0 @@ 9:\] 
 #%g[X!'[ab"...G;@[(4(@(@@$M)'H'.$".k8ra   c                J  #    U R                   [        R                  " 5       :w  d  U R                  (       d  gU R                  R                  5        ISh  vN   U R                  US9I Sh  vN   SSS5      ISh  vN   g N, N N	! , ISh  vN  (       d  f       g= f7f)a  
Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file
itself may be deleted automatically, the behavior is platform-specific.

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

Nforce)r   r~   r   r   r   hold_release_serialized)r   r   s     r_   releaseBaseAsyncFileLock.release  sl      		+4>>((--//***777 0//7 0///sZ   AB#BB#B	-B.B	2B#=B>B#B	B#	B BB B#c                 #    U R                   (       d  g U(       d:  U R                  R                  S:  a   U R                  =R                  S-  sl        g [        U 5      U R                  p2[
        R                  SX#5        U R                  5       n [        U5      I S h  vN    [#        U5        U R!                  5         [
        R                  SX#5        g  N7! [        R                   ai  n [        U5      I S h  vN    O=! [         a0  nU R                  5         U R                  [        XV5         S nAOS nAff = fU R!                  5         e S nAff = f! [         a    U R                  5         e f = f7f)Nr   z#Attempting to release lock %s on %szLock %s released on %s)r   r   r   r   rS   r5   r   r   r$   ry   r   r"   r   _commit_release_if_releasedr   r6   _commit_releaser#   )r   r   r   r   release_futurer   release_errors          r_   r   %BaseAsyncFileLock._release_serialized  s5    ~~33a7MM&&!+&!#D4>>;WT446		">222	>* 	.G 3%% 	n#N333  n002,,-OQ]mmn   "	  	,,.	s~   BE:C !C"C 'E 2'E:C E0D>D?DE
D?&D:5E:D??EEE:E77E:c                H    U R                   (       d  U R                  5         g g rx   )r   r   r   s    r_   r   -BaseAsyncFileLock._commit_release_if_released  s     ~~  " ra   c                |   [        U5      (       a.  [        R                  " [        [	        SU5      " 5       5      5      $ [        R
                  " 5       n[	        SU5      nU R                  (       a!  UR                  U R                  [        U5      $ UR                  5       nUR                  [        U5      5        U$ )Nz)Callable[[], Coroutine[None, None, None]]zCallable[[], None])r   ry   create_taskr    r   get_running_looprP   rQ   r!   create_future
set_result)r   methodrO   sync_methodfutures        r_   r   (BaseAsyncFileLock._start_internal_method  s     v&&&&'9$?jlr:s:u'vww'')/8''}kRR8<8J8J8L-45ra   c                    U R                  [        U R                  5      (       a  U R                  5      $ U R                  5      $ rx   )r   r   _release!_release_with_fork_tracking_async_release_with_fork_trackingr   s    r_   r   (BaseAsyncFileLock._start_tracked_release  sD    **"4==11 22
 	
 11
 	
ra   c                  #    [        U 5          [        SU R                  5      " 5       I S h  vN    U R                  5          S S S 5        U R                  (       a  U R                  5       I S h  vN   g g  NI! [         a   nU R	                  U5      I S h  vN    e S nAff = f! [         a   nU R                  U5      I S h  vN    e S nAff = f! , (       d  f       N= f Ns7fNzCallable[[], Awaitable[None]])	r   r   r   r   _rollback_failed_acquire_async_register_context_descriptor#_rollback_failed_registration_asyncr   _invoke_on_acquired_async)r   acquisition_errorregistration_errors      r_   r   3BaseAsyncFileLock._acquire_with_fork_tracking_async  s     d#:DMMJLLL113 $ >>00222  M  99:KLLL
 ! >>?QRRR $# 3s   C'CA:A8A:B',C'1C%2C'8A::
B$BBBB$$C'
C1CCCCC
C"C'c                  #    U R                   (       d  g S nS n U R                  5          [	        U R                  5       5      I S h  vN   Ub  [        SXU5        g g ! [         a:  nUn U R                  5          S nANV! [         a  nUn S nA S nANkS nAff = fS nAff = f N]! [         a0  nUc  Uc  U R                  X5        [        SUUUU5         S nANS nAff = f7f)Nzlock acquisition cleanup failed)r   r   r   '_register_unverified_context_descriptorr"   r   r   r   )r   r   r  tracking_errorr   r   s         r_   r   0BaseAsyncFileLock._rollback_failed_acquire_async  s     ~~37/3	'--/	 ; ; =>>> )!13DZh *'  	'!&'<<>>  '!&'	' ? 		!)n.D334EV!1!" 		s   C$A B' B%B' C$
B"(B+B ;C$ 
B
BBC$BBB""C$%B' '
C!1&CC$C!!C$c                  #    S n U R                  5          [        U R                  5       5      I S h  vN   Ub  [	        SX5        g g ! [         a  nUn S nANDS nAff = f N.! [         a  n[	        SXU5         S nANHS nAff = f7f)Nz&descriptor registration cleanup failed)r  r   r"   r   r   )r   r  r  r   r   s        r_   r   5BaseAsyncFileLock._rollback_failed_registration_async=  s     /3	#88:	 ; ; =>>>
 %!"JL^o &  	#"N	# ? 	!8:L^l 	s`   BA	 A$ A"A$ B	
AABAB"A$ $
B.B ;B BBc                  #    U R                   b  U R                  R                  S:w  a  g  U R                  [        SU R                  R                  5      5        g ! [
         ac  nUR                  n [        U R                  5       5      I S h  vN    X!l        e ! [
         a  n[        X5         S nAX!l        e S nAff = fS nAff = f7f)Nr   rd   )
r   r   r   r   lock_file_fdr   r   r"   r   r   )r   callback_errorcallback_contextr   s       r_   r   +BaseAsyncFileLock._invoke_on_acquired_asyncM  s     $(B(Ba(G		d5$--*D*DEF 	-99G#D$?$?$ABBB *:& ! G'FF)9&G		s^   )C/A C
C	&C3BBBC
C&B<1C<CCC		Cc                   #    [        U 5          [        SU R                  5      " 5       I S h  vN   U R                  5          S S S 5        g  N! U R                  5         f = f! , (       d  f       g = f7fr   )r   r   r   _unregister_released_descriptorr   s    r_   r   3BaseAsyncFileLock._release_with_fork_tracking_async[  sW     d#7:DMMJLLL446	 $#L446	 $#sB   A5A$AAAA$	A5AA!!A$$
A2.A5c                    Sn[        U5      e)zTSync context manager entry is not supported because lock acquisition is a coroutine.aUse `async with`: acquire/release are coroutines and cannot be awaited in a sync context manager.NotImplementedError)r   r]   s     r_   	__enter__BaseAsyncFileLock.__enter__b  s    q!#&&ra   c                    Sn[        U5      e)zOSync context manager exit is not supported because lock release is a coroutine.r  r  )r   exc_type	exc_value	tracebackr]   s        r_   __exit__BaseAsyncFileLock.__exit__g  s     r!#&&ra   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_   
__aenter__BaseAsyncFileLock.__aenter__q  s       lln 	s   c                B   #    U R                  U5      I Sh  vN   g N7f)z
Release the lock, reconciling a release failure with any body failure per :attr:`context_error_policy`.

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

N)_release_in_contextr   r  r  r  s       r_   	__aexit__BaseAsyncFileLock.__aexit__{  s      &&y111s   c                v  #     U R                  5       I S h  vN   g  N! [         a  nUc  e U R                  S:X  a  [        X!5        e [	        U[
        [        [        45      =n b9  U a4   S:H  a.  u  =[        R                  S` =b  u   pE[        [        XU5        O      [        X5         S nAg S nAff = f7f)NrC      rW   )r   r   r   r   r   r6   r9   r:   ry   r   r   r7   r   )r   
body_errorr   errorsr   backend_errors         r_   r!  %BaseAsyncFileLock._release_in_context  s     	?,,.   	?!))W4)-D)!6<>`a 
  RRB'002R-.KZgtu S#J>>#	?s7   B9  B9 
B6BB1,B91B66B9c                   [        U 5      R                  S5      [        R                  " 5       :w  a  g[        R
                  " [        5          [        R                  " 5       nUc
   SSS5        g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! [         a_    U R                  R                  (       a?  U R                  R                  R                  5       (       d  U R                  R                  OSn Nf = f! , (       d  f       g= f)zORelease on deletion; safe to call during GC even when no event loop is running.r   NTr   )varsgetr~   r   
contextlibsuppress	Exceptionry   r   RuntimeErrorr   rO   	is_closed
is_runningrun_until_completer   r   )r   rO   s     r_   __del__BaseAsyncFileLock.__del__  s    :>>.)RYY[8  +q//1 | ,+ ??$$''4(@A  D!9: ,+   q-1]]-?-?HZHZHdHdHfHft}}))lpq ,+s8   D8C$D81AD8A&D52D84D55D88
E)
r   r   r   r   r   r   r   r   r   r   )rj   zHashable | None)"rS   rb   rT   rc   rU   rd   rV   re   rF   re   rG   re   rH   rc   rI   rf   rJ   r   rK   r   rL   re   rM   re   rN   rg   rO   rh   rP   re   rQ   ri   rj   None)rj   re   )rj   ri   )r   ri   rj   r7  )rj   rh   )NN)
rT   rf   rH   rf   rF   zbool | Noner   Callable[[], bool] | Nonerj   r   )rF   re   r   r8  rT   rc   rH   rc   r   rc   rj   r   )rF   re   r   r8  rT   rc   rH   rc   r   rc   rj   r7  )rj   r7  )r   asyncio.CancelledErrorrj   r	   )r   r   r   r   rj   r	   rx   )
r   rs   r   r9  r   r   r   BaseException | Nonerj   r	   )F)r   re   rj   r7  )r   z>Callable[[], None] | Callable[[], Coroutine[None, None, None]]rj   %asyncio.Future[_BackendOutcome[None]])rj   r;  )r   r   rj   r7  )r  r   rj   r7  )rj   r	   r  ztype[BaseException] | Noner  r:  r  zTracebackType | Nonerj   r7  )rj   r3   )r'  r:  rj   r7  ))rk   rl   rm   rn   __doc__rt   __annotations__rv   staticmethodr{   r   r   propertyrP   rQ   setterrO   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r#  r!  r5  ro   rW   ra   r_   r<   r<   u   sT    "K3J45,c5& & $"Z$ "#!%3:/8!%#(4815 $,0%Z$)Z$ Z$ 	Z$
 Z$ Z$ Z$ Z$ Z$ 1Z$ -Z$ Z$ !Z$ 2Z$  /!Z$" #Z$$ *%Z$& 
'Z$x - - & & __' ' " " !%&*;4
 !%26;4;4 $;4
 ;4 0;4 
!;4z"6 "6 0	"6
 "6 "6 "6 
!"6H/ / 0	/
 / / / 
/>)JV= .299 -9 #	9
 +9 
9.8H8#T	.
3>p 7'
',' (' (	'
 
'2,2 (2 (	2
 
2 ?.?	?2;ra   )	metaclassc                  D    \ rS rSr% SrSrS\S'   SrS\S'   SrS	\S
'   Sr	g)r   i  zGA dataclass which holds the context for a ``BaseAsyncFileLock`` object.Tre   rP   Nri   rQ   rh   rO   rW   )
rk   rl   rm   rn   r=  rP   r>  rQ   rO   ro   rW   ra   r_   r   r     s+    Q !OT  )-H%, .2D
*1ra   r   c                      \ rS rSrSrSrg)r   i  z8A thread local version of the ``FileLockContext`` class.rW   Nrk   rl   rm   rn   r=  ro   rW   ra   r_   r   r     s    Bra   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)r   i  zDA context-aware object that will release the lock file when exiting.c                    Xl         g rx   r   )r   r   s     r_   r    AsyncAcquireReturnProxy.__init__  s    	ra   c                "   #    U R                   $ 7frx   r   r   s    r_   r  "AsyncAcquireReturnProxy.__aenter__  s     yys   c                V   #    U R                   R                  U5      I S h  vN   g  N7frx   )r   r!  r"  s       r_   r#  !AsyncAcquireReturnProxy.__aexit__  s      ii++I666s   )')r   N)r   r<   rj   r7  )rj   r<   r<  )	rk   rl   rm   rn   r=  r   r  r#  ro   rW   ra   r_   r   r     s:    N7,7 (7 (	7
 
7ra   r   c                  (    \ rS rSr% SrSrS\S'   Srg)AsyncSoftFileLocki  z.Simply watches the existence of the lock file.)AsyncStrictSoftFileLockAsyncSoftFileLeaseztuple[str, str] | None_lifetime_replacementsrW   N)rk   rl   rm   rn   r=  rQ  r>  ro   rW   ra   r_   rN  rN    s    85f2fra   rN  c                      \ rS rSrSrSrg)rO  i  z?Run strict owner-claim locking without blocking the event loop.rW   NrE  rW   ra   r_   rO  rO    s    Ira   rO  c                      \ rS rSrSrSrg)rP  i  z_Existence lock whose claim expires, so a peer may take it while the previous holder still runs.rW   NrE  rW   ra   r_   rP  rP    s    ira   rP  c                      \ rS rSrSrSrg)AsyncUnixFileLocki  zHUses the :func:`fcntl.flock` to hard lock the lock file on unix systems.rW   NrE  rW   ra   r_   rU  rU    s    Rra   rU  c                      \ rS rSrSrSrg)AsyncWindowsFileLocki  zNUses the :func:`msvcrt.locking` to hard lock the lock file on windows systems.rW   NrE  rW   ra   r_   rW  rW    s    Xra   rW  )r   rP  rN  rO  rU  rW  r<   )Zr=  
__future__r   ry   r.  loggingr~   r   dataclassesr   inspectr   	threadingr   typingr   r   r	   r
   r   _apir   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _asyncr   r   r   r    r!   r"   r#   r$   _errorr%   _leaser&   _softr'   _strictr(   _unixr)   _windowsr*   syscollections.abcr+   r,   r-   r.   
concurrentr/   typesr0   version_infor3   typing_extensions	getLoggerr5   r>  r6   r7   r9   r:   r;   r?   r<   r   r   r   rN  rO  rP  rU  rW  __all__rW   ra   r_   <module>rn     s   7 "    	  ! '  @ @    $	 	 	  !  '  %HH"#
7"* ")!2!2:!>	 >1l "J l,l z l6\ ' \8: "$5 :e./+
 +
\};0A };@ 
2? 
2 
2C"6 C7 7$g&7 gJ02C Jj(9 jS&7 SY?,= Yra   