← Back
Editing: async_helpers.cpython-311.pyc
� �@�c� � � � d Z ddlZddlZddlZddlmZ dad� Z G d� d� � Z e� � Z G d� d� � Z d � Zd � Zd� Z ded efd�ZdS )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 � � t j � � S # t $ r Y nw xY wt �t � � � rt j � � at S )aZ 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 sg � � ��'�)�)�)��� � � � �� ���� �"�&9�&C�&C�&E�&E�"�%�4�6�6���s � � "�"c � � e Zd Zd� Zd� ZdS )�_AsyncIORunnerc �D � t � � � |� � S )z/ Handler for asyncio autoawait )r �run_until_complete)�self�coros r �__call__z_AsyncIORunner.__call__4 s � � �!�!�4�4�T�:�:�:r c � � dS )Nr r �r s r �__str__z_AsyncIORunner.__str__: s � ��yr N)�__name__� __module__�__qualname__r r r r r r r 3 s2 � � � � � �;� ;� ;�� � � � r r c �* � e Zd ZdZd� Zd� Zd� Zd� ZdS )� _AsyncIOProxyz^Proxy-object for an asyncio Any coroutine methods will be wrapped in event_loop.run_ c �"