+
    ^|i                         R t ^ RIt^ RIt^ RIt^ RIHt RsR t ! R R4      t]! 4       t	 ! R R4      t
R tR	 tR
 tR R ltR# )a  
Async helper function that are invalid syntax on Python 3.5 and below.

This code is best effort, and may have edge cases not behaving as expected. In
particular it contain a number of heuristics to detect whether code is
effectively async and need to run in an event loop or not.

Some constructs (like top-level `return`, or `yield`) are taken care of
explicitly to actually raise a SyntaxError and stay as close as possible to
Python semantics.
N)wrapsc                      \         P                  ! 4       #   \         d     Mi ; i\        e   \        P	                  4       '       d   \         P
                  ! 4       s\        # )a:  asyncio has deprecated get_event_loop

Replicate it here, with our desired semantics:

- always returns a valid, not-closed loop
- not thread-local like asyncio's,
  because we only want one loop for IPython
- if called from inside a coroutine (e.g. in ipykernel),
  return the running loop

.. versionadded:: 8.0
)asyncioget_running_loopRuntimeError_asyncio_event_loop	is_closednew_event_loop     </usr/lib/python3/dist-packages/IPython/core/async_helpers.pyget_asyncio_loopr      sV    ''))  	 "&9&C&C&E&E%446s    %%c                   ,   a  ] tR t^2t o R tR tRtV tR# )_AsyncIORunnerc                4    \        4       P                  V4      # )z
Handler for asyncio autoawait
)r   run_until_complete)selfcoros   &&r   __call___AsyncIORunner.__call__3   s      !44T::r   c                    R # )r   r
   r   s   &r   __str___AsyncIORunner.__str__9   s    r   r
   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r   2   s     ; r   r   c                   <   a  ] tR t^@t o RtR tR tR tR tRt	V t
R# )_AsyncIOProxyzVProxy-object for an asyncio

Any coroutine methods will be wrapped in event_loop.run_
c                    Wn         W n        R # N)_obj_event_loop)r   obj
event_loops   &&&r   __init___AsyncIOProxy.__init__F   s    	%r   c                $    R V P                   : R2# )z<_AsyncIOProxy(z)>)r&   r   s   &r   __repr___AsyncIOProxy.__repr__J   s     R00r   c                   a a \        S P                  V4      o\        P                  ! S4      '       d   \	        S4      VV 3R  l4       pV# S# )c                  ~   < \         P                  ! S! V / VB SP                  4      p\         P                  ! V4      # r%   )r   run_coroutine_threadsafer'   wrap_future)argskwargsconcurrent_futureattrr   s   *, r   _wrapped+_AsyncIOProxy.__getattr__.<locals>._wrappedR   s=    $+$D$D$)&)4+;+;%! **+<==r   )getattrr&   inspectiscoroutinefunctionr   )r   keyr7   r6   s   f& @r   __getattr___AsyncIOProxy.__getattr__M   sH    tyy#&&&t,, 4[> > OKr   c                ,    \        V P                  4      # r%   )dirr&   r   s   &r   __dir___AsyncIOProxy.__dir__]   s    499~r   )r'   r&   N)r   r   r   r   __doc__r*   r-   r=   rA   r   r   r    s   @r   r#   r#   @   s#     
&1  r   r#   c                ,    ^ RI pVP                  V 4      # )z
handler for curio autoawait
N)curiorun)	coroutinerE   s   & r   _curio_runnerrH   a   s     99Yr   c                 2    ^ RI pR pVP                  W 4      # )    Nc                "   "   V G Rj  xL
 #  L5i)zv
We need the dummy no-op async def to protect from
trio's internal. See https://github.com/python-trio/trio/issues/89
Nr
   )r   s   &r   loc_trio_runner.<locals>.locm   s     
 zzs   )triorF   )async_fnrN   rL   s   &  r   _trio_runnerrP   j   s     88C""r   c                     V P                  R4       \        RP                  V P                  R7      4      h  \         d   pTP
                  u Rp?# Rp?ii ; i)z
A runner that does not really allow async execution, and just advance the coroutine.

See discussion in https://github.com/python-trio/trio/issues/608,

Credit to Nathaniel Smith
Nz%{coro_name!r} needs a real async loop)	coro_name)sendr   formatr   StopIterationvalue)r   excs   & r   _pseudo_sync_runnerrX   w   sR    
		$
 3::T]]:S
 	
	  yys   8 AAAAc                0    V ^8  d   QhR\         R\        /# )   cellreturn)strbool)rT   s   "r   __annotate__r_      s      3 4 r   c           
          \        V RR\        \        R^ 4      R7      p\        P                  VP
                  ,          \        P                  8H  #   \        \        \        3 d     R# i ; i)zDetect if a block of code needs to be wrapped in an `async def`

If the code block has a top-level return statement or is otherwise
invalid, `False` will be returned.
z<>execPyCF_ALLOW_TOP_LEVEL_AWAIT)flagsF)	compiler9   astr:   CO_COROUTINEco_flagsSyntaxError
ValueErrorMemoryError)r[   codes   & r   _should_be_asyncrl      s`    $gc3OQT&U
 ##dmm3w7K7KKK[1 s   AA A,+A,)rC   re   r   r:   	functoolsr   r   r   r   _asyncio_runnerr#   rH   rP   rX   rl   r
   r   r   <module>ro      sV   
     :  !" B 
#
&r   