asyncio.pyc
1 o 2 ��c�f � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl 3 Z 4 ddlZddlZddl mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZ ejroddlmZ ddlmZ G dd � d e�Zee ef Z!ed 5 �Z"e#� Z$d$dd �Z%e�&e%� e j'dkr�dej(fdd�Z)nddlm*Z) G dd� de�Z+G dd� de+�Z,G dd� de+�Z-dej.dej.fdd�Z/dej.dej.fdd�Z0e j1dkr�e2ed�r�ej3Z4nej5Z4G d d!� d!e4�Z6G d"d#� d#ej(�Z7dS )%ak Bridges between the `asyncio` module and Tornado IOLoop. 6 7 .. versionadded:: 3.2 8 9 This module integrates Tornado with the ``asyncio`` module introduced 10 in Python 3.4. This makes it possible to combine the two libraries on 11 the same event loop. 12 13 .. deprecated:: 5.0 14 15 While the code in this module is still used, it is now enabled 16 automatically when `asyncio` is available, so applications should 17 no longer need to refer to this module directly. 18 19 .. note:: 20 21 Tornado is designed to use a selector-based event loop. On Windows, 22 where a proactor-based event loop has been the default since Python 3.8, 23 a selector event loop is emulated by running ``select`` on a separate thread. 24 Configuring ``asyncio`` to use a selector event loop may improve performance 25 of Tornado (but may reduce performance of other ``asyncio``-based libraries 26 in the same process). 27 � N��convert_yielded)�IOLoop�_Selectable) �Any�TypeVar� Awaitable�Callable�Union�Optional�List�Tuple�Dict)�Set)�Protocolc @ s e Zd Zdefdd�ZdS )� 28 _HasFileno�returnc C � d S �N� ��selfr r ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tornado\platform\asyncio.py�fileno. s z_HasFileno.filenoN)�__name__� 29 __module__�__qualname__�intr r r r r r - s r �_Tr c C sz t D ]4} | j� d| _| j�� W d � n1 sw Y z| j�d� W n ty0 Y nw | j�� qt � � d S )NT� a) 30 �_selector_loops�_select_cond�_closing_selector�notify�_waker_w�send�BlockingIOError�_thread�join�clear)�loopr r r �_atexit_callback: s ��r+ )� � 31 c C s* zt �� W S ty Y nw t �� �� S r )�asyncio�get_running_loop�RuntimeError�get_event_loop_policy�get_event_loopr r r r �_get_event_loopO s 32 �r3 )r2 c 33 sp e Zd Zdejdeddf� fdd�Zd.deddfd d 34 �Zde e 35 ef ded de 36 ddfdd�Z de e 37 ef de 38 ddfdd�Zde e 39 ef ddfdd�Zde 40 de 41 ddfdd�Zd/dd�Zd/dd�Zdededededef 42 dd�Zd eddfd!d"�Zdedededdfd#d$�Zdedededdfd%d&�Zd'eejj d(ed)ef dedee fd*d+�Zd'ejjddfd,d-�Z � Z!S )0�BaseAsyncIOLoop�asyncio_loop�kwargsr Nc s� || _ || _ttd�rt|tj�rt|�| _i | _t� | _ t� | _ 43 d| _tj �� D ]}|�� r?ztj |= W q) ty> Y q)w q)tj �|| �}|| urUtd|� d|� ���t� jdi |�� d S )N�ProactorEventLoopFzIOLoop z& already associated with asyncio loop r )r5 � selector_loop�hasattrr. � 44 isinstancer7 �AddThreadSelectorEventLoop�handlers�set�readers�writers�closingr �_ioloop_for_asyncio�copy� is_closed�KeyError� 45 setdefaultr0 �super� 46 initialize)r r5 r6 r* Z existing_loop�� __class__r r rG ] s0 � 47 ���zBaseAsyncIOLoop.initializeF�all_fdsc C sj d| _ t| j�D ]}| j| \}}| �|� |r| �|� qtj| j= | j| jur.| j� � | j� � d S �NT) 48 r@ �listr<