BYPASS SHELL BY ./RAZORGANZ
Server: nginx/1.20.1
System: Linux iZdzfnv9mwfppeZ 5.10.134-19.2.al8.x86_64 #1 SMP Wed Oct 29 22:47:09 CST 2025 x86_64
User: apache (48)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib64/python3.6/site-packages/tornado/platform/__pycache__/asyncio.cpython-36.pyc
3

	��f�/�@s�dZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlZddlZddlm
Z
mZmZmZmZmZejr�ddlmZmZmZed�ZGd	d
�d
e	�ZGdd�de�ZGd
d�de�Zejejd�dd�Zejejd�dd�ZGdd�dej�ZdS)a�Bridges between the `asyncio` module and Tornado IOLoop.

.. versionadded:: 3.2

This module integrates Tornado with the ``asyncio`` module introduced
in Python 3.4. This makes it possible to combine the two libraries on
the same event loop.

.. deprecated:: 5.0

   While the code in this module is still used, it is now enabled
   automatically when `asyncio` is available, so applications should
   no longer need to refer to this module directly.

.. note::

   Tornado requires the `~asyncio.AbstractEventLoop.add_reader` family of
   methods, so it is not compatible with the `~asyncio.ProactorEventLoop` on
   Windows. Use the `~asyncio.SelectorEventLoop` instead.
�N)�	get_ident)�convert_yielded)�IOLoop�_Selectable)�Any�TypeVar�	Awaitable�Callable�Union�Optional)�Set�Dict�Tuple�_TcsHeZdZejedd��fdd�Zd+edd�dd�Ze	e
efed,e
dd
�dd�Z
e	e
efe
dd
�dd�Ze	e
efdd�dd�Ze
e
dd
�dd�Zdd�dd�Zdd�dd�Zeed-eeed�dd�Zedd�dd�Zeeedd �d!d"�Zeeedd �d#d$�Zeejjed	efeeed%�d&d'�Zejjdd(�d)d*�Z �Z!S).�BaseAsyncIOLoopN)�asyncio_loop�kwargs�returncs�|�_i�_t��_t��_d�_x"ttj�D]}|j	�r.tj|=q.W�tj|<d�_
tt��j
f|�dd��fdd�}�j|�dS)NFr)rcst��_dS)N)r�_thread_identity�)�selfr�/usr/lib64/python3.6/asyncio.py�assign_thread_identityGsz:BaseAsyncIOLoop.initialize.<locals>.assign_thread_identity)r�handlers�set�readers�writers�closing�listr�_ioloop_for_asyncioZ	is_closedr�superr�
initialize�add_callback)rrr�loopr)�	__class__)rrr!)s
zBaseAsyncIOLoop.initializeF)�all_fdsrcCsXd|_x8t|j�D]*}|j|\}}|j|�|r|j|�qWtj|j=|jj�dS)NT)	rrr�remove_handlerZclose_fdrrr�close)rr%�fd�fileobj�handler_funcrrrr'Ls

zBaseAsyncIOLoop.close.)r(�handler�eventsrcCs�|j|�\}}||jkr$td|��||f|j|<|tj@r^|jj||j|tj�|jj	|�|tj
@r�|jj||j|tj
�|jj	|�dS)Nzfd %s added twice)
�split_fdr�
ValueErrorr�READr�
add_reader�_handle_eventsr�add�WRITE�
add_writerr)rr(r+r,r)rrr�add_handler[s


zBaseAsyncIOLoop.add_handler)r(r,rcCs�|j|�\}}|tj@rF||jkrh|jj||j|tj�|jj|�n"||jkrh|jj|�|jj	|�|tj
@r�||jkr�|jj||j|tj
�|jj|�n"||jkr�|jj
|�|jj	|�dS)N)r-rr/rrr0r1r2�
remove_reader�remover3rr4�
remove_writer)rr(r,r)rrr�update_handleris





zBaseAsyncIOLoop.update_handler)r(rcCsl|j|�\}}||jkrdS||jkr>|jj|�|jj|�||jkr`|jj|�|jj|�|j|=dS)N)r-rrrr6r7rr8)rr(r)rrrr&|s


zBaseAsyncIOLoop.remove_handlercCs|j|\}}|||�dS)N)r)rr(r,r)r*rrrr1�szBaseAsyncIOLoop._handle_events)rcCs^ytj�}Wnttfk
r(d}YnXz"|j�tj|j�|jj�Wdtj|�XdS)N)�asyncio�get_event_loop�RuntimeError�AssertionErrorZ_setup_logging�set_event_looprZrun_forever)rZold_looprrr�start�s
zBaseAsyncIOLoop.startcCs|jj�dS)N)r�stop)rrrrr@�szBaseAsyncIOLoop.stop)�when�callback�argsrrcOs.|jjtd||j��|jtj|f|�|��S)Nr)rZ
call_later�maxZtime�
_run_callback�	functools�partial)rrArBrCrrrr�call_at�szBaseAsyncIOLoop.call_at)�timeoutrcCs|j�dS)N)Zcancel)rrIrrr�remove_timeout�szBaseAsyncIOLoop.remove_timeout)rBrCrrcOsVt�|jkr|jj}n|jj}y||jtj|f|�|��Wntk
rPYnXdS)N)	rrr�	call_soon�call_soon_threadsaferErFrGr<)rrBrCrrKrrrr"�s
zBaseAsyncIOLoop.add_callbackcOs<y"|jj|jtj|f|�|��Wntk
r6YnXdS)N)rrLrErFrGr<)rrBrCrrrr�add_callback_from_signal�s
z(BaseAsyncIOLoop.add_callback_from_signal)�executor�funcrCrcGs|jj||f|��S)N)r�run_in_executor)rrNrOrCrrrrP�szBaseAsyncIOLoop.run_in_executor)rNrcCs|jj|�S)N)r�set_default_executor)rrNrrrrQ�sz$BaseAsyncIOLoop.set_default_executor)F).N).N)"�__name__�
__module__�__qualname__r:�AbstractEventLooprr!�boolr'r
�intrr	r5r9r&r1r?r@�float�objectrHrJr"rMr�
concurrentZfuturesZExecutorrrrPrQ�
__classcell__rr)r$rr(s*!



rcs6eZdZdZedd��fdd�Zdd�dd�Z�ZS)	�AsyncIOMainLoopa�``AsyncIOMainLoop`` creates an `.IOLoop` that corresponds to the
    current ``asyncio`` event loop (i.e. the one returned by
    ``asyncio.get_event_loop()``).

    .. deprecated:: 5.0

       Now used automatically when appropriate; it is no longer necessary
       to refer to this class directly.

    .. versionchanged:: 5.0

       Closing an `AsyncIOMainLoop` now closes the underlying asyncio loop.
    N)rrcstt|�jtj�f|�dS)N)r r\r!r:r;)rr)r$rrr!�szAsyncIOMainLoop.initialize)rcCsdS)Nr)rrrr�make_current�szAsyncIOMainLoop.make_current)rRrSrT�__doc__rr!r]r[rr)r$rr\�s
r\csZeZdZdZedd��fdd�Zdedd��fdd	�
Zdd
�dd�Zdd
�d
d�Z	�Z
S)�AsyncIOLoopa�``AsyncIOLoop`` is an `.IOLoop` that runs on an ``asyncio`` event loop.
    This class follows the usual Tornado semantics for creating new
    ``IOLoops``; these loops are not necessarily related to the
    ``asyncio`` default event loop.

    Each ``AsyncIOLoop`` creates a new ``asyncio.EventLoop``; this object
    can be accessed with the ``asyncio_loop`` attribute.

    .. versionchanged:: 5.0

       When an ``AsyncIOLoop`` becomes the current `.IOLoop`, it also sets
       the current `asyncio` event loop.

    .. deprecated:: 5.0

       Now used automatically when appropriate; it is no longer necessary
       to refer to this class directly.
    N)rrcsJd|_tj�}ytt|�j|f|�Wntk
rD|j��YnXdS)NF)�
is_currentr:�new_event_loopr r_r!�	Exceptionr')rrr#)r$rrr!�szAsyncIOLoop.initializeF)r%rcs$|jr|j�tt|�j|d�dS)N)r%)r`Z
clear_currentr r_r')rr%)r$rrr'szAsyncIOLoop.close)rcCsJ|js:ytj�|_Wnttfk
r2d|_YnXd|_tj|j�dS)NT)r`r:r;�old_asyncior<r=r>r)rrrrr]szAsyncIOLoop.make_currentcCs|jrtj|j�d|_dS)NF)r`r:r>rc)rrrr�_clear_current_hookszAsyncIOLoop._clear_current_hook)F)rRrSrTr^rr!rVr'r]rdr[rr)r$rr_�s
	r_)�asyncio_futurercCs|S)z�Convert an `asyncio.Future` to a `tornado.concurrent.Future`.

    .. versionadded:: 4.1

    .. deprecated:: 5.0
       Tornado ``Futures`` have been merged with `asyncio.Future`,
       so this method is now a no-op.
    r)rerrr�to_tornado_futures	rf)�tornado_futurercCst|�S)asConvert a Tornado yieldable object to an `asyncio.Future`.

    .. versionadded:: 4.1

    .. versionchanged:: 4.3
       Now accepts any yieldable object, not just
       `tornado.concurrent.Future`.

    .. deprecated:: 5.0
       Tornado ``Futures`` have been merged with `asyncio.Future`,
       so this method is now equivalent to `tornado.gen.convert_yielded`.
    )r)rgrrr�to_asyncio_future&s
rhcs(eZdZdZejd��fdd�Z�ZS)�AnyThreadEventLoopPolicyaDEvent loop policy that allows loop creation on any thread.

    The default `asyncio` event loop policy only automatically creates
    event loops in the main threads. Other threads must create event
    loops explicitly or `asyncio.get_event_loop` (and therefore
    `.IOLoop.current`) will fail. Installing this policy allows event
    loops to be created automatically on any thread, matching the
    behavior of Tornado versions prior to 5.0 (or 5.0 on Python 2).

    Usage::

        asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())

    .. versionadded:: 5.0

    )rcs:y
t�j�Sttfk
r4|j�}|j|�|SXdS)N)r r;r<r=rar>)rr#)r$rrr;Hs

z'AnyThreadEventLoopPolicy.get_event_loop)rRrSrTr^r:rUr;r[rr)r$rri6sri) r^�concurrent.futuresrZrFZ	threadingrZtornado.genrZtornado.iolooprrr:Ztypingrrrr	r
rZ
TYPE_CHECKINGrr
rrrr\r_ZFuturerfrhZDefaultEventLoopPolicyrirrrr�<module>s$ (3