
    ,h#                       S SK Jr  S SKrS SKJ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
  S SKJr  S S	KJr  S S
KJr  S SKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \" S5      r\R                  (       a   " S S\5      rS/S jrOS SKJr  S SKJr  \" \" 5       S5      rS0S jr " S S\5      r \" SS S!9r!\(       a
      S1S" jr"O\RD                  r"S2S# jr#S3S$ jr$S4S% jr%S4S& jr&S'S(.         S5S) jjr' " S* S+5      r(S6S, jr)\(       d  \(       a  \RT                  r+g " S- S.5      r+g)7    )annotationsN)Context)Any)	Awaitable)Callable)	Coroutine)Optional)TYPE_CHECKING)TypeVar)Union   )memoized_property   )exc)py311)Literal)Protocol)Self)	TypeGuard_Tc                  H    \ rS rSr% S\S'   S\S'   SS jrSS jrSS jrS	rg
)greenlet$   booldeadzOptional[Context]
gr_contextc                    g N selffndrivers      Y/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/util/_concurrency_py3k.py__init__greenlet.__init__(   s    c    c                    g r   r   )r!   args     r$   throwgreenlet.throw*       r'   c                    g r   r   )r!   values     r$   switchgreenlet.switch-   r,   r'   r   Nr"   zCallable[..., Any]r#   r   )r)   r   returnr   )r.   r   r2   r   )	__name__
__module____qualname____firstlineno____annotations__r%   r*   r/   __static_attributes__r   r'   r$   r   r   $   s    
%%I		r'   r   c                     g r   r   r   r'   r$   
getcurrentr:   0   s    #r'   )r:   )r   r   c                    [        U [        5      (       + =(       d*    [        U [        R                  [        R                  45      $ r   )
isinstance	ExceptionasyncioTimeoutErrorCancelledError)es    r$   is_exit_exceptionrB   =   s8     !Y'' :	G  '"8"89, r'   c                  .    \ rS rSr% S\S'   SrSS jrSrg)	_AsyncIoGreenletJ   r   r   Tc                l    [         R                  " XU5        [        (       a  UR                  U l        g g r   )r   r%   _has_gr_contextr   r    s      r$   r%   _AsyncIoGreenlet.__init__O   s)    $F+?$//DO r'   )r   Nr1   )r3   r4   r5   r6   r7    __sqlalchemy_greenlet_provider__r%   r8   r   r'   r$   rD   rD   J   s    
J'+$0r'   rD   _T_coT)	covariantc                    g r   r   	awaitables    r$   iscoroutinerO   Y   s    03r'   c                F    [        U 5      (       a  U R                  5         g g r   )rO   closerM   s    r$   _safe_cancel_awaitablerR   a   s     9 r'   c                 0    [        5       n [        U SS5      $ )NrI   F)r:   getattr)currents    r$   in_greenletrV   h   s    lG7>FFr'   c                    [        5       n[        USS5      (       d!  [        U 5        [        R                  " S5      eUR
                  R                  U 5      $ )zAwaits an async function in a sync method.

The sync method must be inside a :func:`greenlet_spawn` context.
:func:`await_only` calls cannot be nested.

:param awaitable: The coroutine to call.

rI   Fzjgreenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?)r:   rT   rR   r   MissingGreenletparentr/   )rN   rU   s     r$   
await_onlyrZ   m   sR     lG7>FFy)!!=
 	
 >>  ++r'   c                   [        5       n[        USS5      (       dQ  [        5       nUR                  5       (       a!  [	        U 5        [
        R                  " S5      eUR                  U 5      $ UR                  R                  U 5      $ )a  Awaits an async function in a sync method.

The sync method must be inside a :func:`greenlet_spawn` context.
:func:`await_fallback` calls cannot be nested.

:param awaitable: The coroutine to call.

.. deprecated:: 2.0.24 The ``await_fallback()`` function will be removed
   in SQLAlchemy 2.1.  Use :func:`_util.await_only` instead, running the
   function / program / etc. within a top-level greenlet that is set up
   using :func:`_util.greenlet_spawn`.

rI   Fzgreenlet_spawn has not been called and asyncio event loop is already running; can't call await_fallback() here. Was IO attempted in an unexpected place?)
r:   rT   get_event_loop
is_runningrR   r   rX   run_until_completerY   r/   )rN   rU   loops      r$   await_fallbackr`      sx      lG7>FF??"9-%%; 
 &&y11>>  ++r'   F)_require_awaitc                 #    [        U [        5       5      nSnUR                  " U0 UD6nUR                  (       d1  Sn UI Sh  vN nUR                  U5      nUR                  (       d  M1  U(       a  U(       d  [        R                  " S5      eU$  NN! [         a%    UR
                  " [        R                  " 5       6 n Nif = f7f)a/  Runs a sync function ``fn`` in a new greenlet.

The sync function can then use :func:`await_only` to wait for async
functions.

:param fn: The sync callable to call.
:param \*args: Positional arguments to pass to the ``fn`` callable.
:param \*\*kwargs: Keyword arguments to pass to the ``fn`` callable.
FTNzThe current operation required an async execution but none was detected. This will usually happen when using a non compatible DBAPI driver. Please ensure that an async DBAPI is used.)
rD   r:   r/   r   BaseExceptionr*   sysexc_infor   AwaitRequired)r"   ra   argskwargscontextswitch_occurredresultr.   s           r$   greenlet_spawnrl      s     " r:<0G
 O^^T,V,Fll
	+ !LE ^^E*F lll oG
 	

 M ! 	4 ]]CLLN3F		4s@   <CB BB 	"C-&CB ,CCCCc                  <    \ rS rSr\SS j5       rSS jrS	S jrSrg)
AsyncAdaptedLock   c                ,    [         R                  " 5       $ r   )r>   Lockr!   s    r$   mutexAsyncAdaptedLock.mutex   s     ||~r'   c                H    [        U R                  R                  5       5      $ r   )r`   rs   acquirerr   s    r$   	__enter__AsyncAdaptedLock.__enter__   s     djj00233r'   c                8    U R                   R                  5         g r   )rs   release)r!   r)   kws      r$   __exit__AsyncAdaptedLock.__exit__   s    

r'   r   N)r2   zasyncio.Lockr2   r   )r)   r   r{   r   r2   None)	r3   r4   r5   r6   r   rs   rw   r|   r8   r   r'   r$   rn   rn      s     
4
r'   rn   c                      [         R                  " 5       $ ! [         a     Of = f[         R                  " 5       R	                  5       $ )zuvendor asyncio.get_event_loop() for python 3.7 and above.

Python 3.10 deprecates get_event_loop() as a standalone.

)r>   get_running_loopRuntimeErrorget_event_loop_policyr\   r   r'   r$   r\   r\      sB    ''))  ((*99;;s    
$$c                  j    \ rS rSr% SrS\S'   SS jrSS 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)_Runner   z#Runner implementation for test onlyz6Union[None, asyncio.AbstractEventLoop, Literal[False]]_loopc                    S U l         g r   r   rr   s    r$   r%   _Runner.__init__   s	    DJr'   c                &    U R                  5         U $ r   )
_lazy_initrr   s    r$   rw   _Runner.__enter__   s    OOKr'   c                $    U R                  5         g r   )rQ   )r!   exc_typeexc_valexc_tbs       r$   r|   _Runner.__exit__  s    JJLr'   c                   U R                   (       aV   U R                   R                  U R                   R                  5       5        U R                   R                  5         SU l         g g ! U R                   R                  5         SU l         f = f)NF)r   r^   shutdown_asyncgensrQ   rr   s    r$   rQ   _Runner.close  si    zz'JJ11

557 JJ$$&!&DJ  JJ$$&!&DJs   3A) )#Bc                `    U R                  5         U R                  (       d   eU R                  $ )zReturn embedded event loop.)r   r   rr   s    r$   get_loop_Runner.get_loop  s"    OO:::::r'   c                ~    U R                  5         U R                  (       d   eU R                  R                  U5      $ r   )r   r   r^   )r!   coros     r$   run_Runner.run  s-    OO:::::0066r'   c                    U R                   SL a  [        S5      eU R                   c  [        R                  " 5       U l         g g )NFzRunner is closed)r   r   r>   new_event_looprr   s    r$   r   _Runner._lazy_init  s9    zzU""#566zz!$335
 "r'   r   N)r2   r   )r2   r   )r   r   r   r   r   r   r2   r   r2   zasyncio.AbstractEventLoop)r   zCoroutine[Any, Any, _T]r2   r   )r3   r4   r5   r6   __doc__r7   r%   rw   r|   rQ   r   r   r   r8   r   r'   r$   r   r      s.    1EE				'		7
	6r'   r   )r2   r   )rA   rc   r2   r   )rN   zAwaitable[_T_co]r2   z%TypeGuard[Coroutine[Any, Any, _T_co]])rN   zAwaitable[Any]r2   r   r~   )rN   zAwaitable[_T]r2   r   )
r"   zCallable[..., _T]rg   r   ra   r   rh   r   r2   r   r   ),
__future__r   r>   contextvarsr   rd   typingr   r   r   r   r	   r
   r   r   langhelpersr    r   utilr   util.typingr   r   r   r   r   r   r:   hasattrrG   rB   rD   rJ   rO   rR   rV   rZ   r`   rl   rn   r\   Runnerr   r   r'   r$   <module>r      s:   #   
           *   ! "  #T]	
8 
 & $! *,50x 0 	4(4#4	.4
 %%KG
,4,F !,,, , 	,
 ,^  < nnG(6 (6r'   