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/__pycache__/concurrent.cpython-36.pyc
3

	��f��@s�dZddlZddlmZddlZddlZddlZddlmZddl	Z	ddl	m
Z
mZmZm
Z
mZe	jd�ZGdd�de�ZejZejefZe
ed	�d
d�ZGdd
�d
ej�Ze�Ze
e
ed�dd�Ze�Zdddd�dd�Zdedd�dd�Zdedd�dd�Z de
ee!eeeej"fdd�dd�Z#e	j$dedgdfdd �d!d"��Z%e	j$dedgdfdd �d#d"��Z%ded&dd �d%d"�Z%dS)'a�Utilities for working with ``Future`` objects.

Tornado previously provided its own ``Future`` class, but now uses
`asyncio.Future`. This module contains utility functions for working
with `asyncio.Future` in a way that is backwards-compatible with
Tornado's old ``Future`` implementation.

While this module is an important part of Tornado's internal
implementation, applications rarely need to interact with it
directly.

�N)�futures)�app_log)�Any�Callable�Optional�Tuple�Union�_Tc@seZdZdS)�ReturnValueIgnoredErrorN)�__name__�
__module__�__qualname__�rr�"/usr/lib64/python3.6/concurrent.pyr
*sr
)�x�returncCs
t|t�S)N)�
isinstance�FUTURES)rrrr�	is_future4src@s:eZdZedefeedd�dd�Zdedd�d	d
�ZdS)�
DummyExecutor.zfutures.Future[_T])�fn�args�kwargsrcOsDtj�}yt||||��Wn"tk
r>t|tj��YnX|S)N)r�Future�"future_set_result_unless_cancelled�	Exception�future_set_exc_info�sys�exc_info)�selfrrr�futurerrr�submit9szDummyExecutor.submitTN)�waitrcCsdS)Nr)rr"rrr�shutdownCszDummyExecutor.shutdown)T)	rrr
rr	rr!�boolr#rrrrr8sr)rrrcsbttdtfd��fdd�}|r,�r,td��t|�dkrD||d�St|�dkr^tdt|���|S)	a�Decorator to run a synchronous method asynchronously on an executor.

    The decorated method may be called with a ``callback`` keyword
    argument and returns a future.

    The executor to be used is determined by the ``executor``
    attributes of ``self``. To use a different attribute name, pass a
    keyword argument to the decorator::

        @run_on_executor(executor='_thread_pool')
        def foo(self):
            pass

    This decorator should not be confused with the similarly-named
    `.IOLoop.run_in_executor`. In general, using ``run_in_executor``
    when *calling* a blocking method is recommended instead of using
    this decorator when *defining* a method. If compatibility with older
    versions of Tornado is required, consider defining an executor
    and using ``executor.submit()`` at the call site.

    .. versionchanged:: 4.2
       Added keyword arguments to use alternative attributes.

    .. versionchanged:: 5.0
       Always uses the current IOLoop instead of ``self.io_loop``.

    .. versionchanged:: 5.1
       Returns a `.Future` compatible with ``await`` instead of a
       `concurrent.futures.Future`.

    .. deprecated:: 5.1

       The ``callback`` argument is deprecated and will be removed in
       6.0. The decorator itself is discouraged in new code but will
       not be removed in 6.0.

    .. versionchanged:: 6.0

       The ``callback`` argument was removed.
    .)rrcs4�jdd��tj��ttttd���fdd��}|S)N�executor)rrrrcs.t�}t|��j�|f|�|�}t||�|S)N)r�getattrr!�chain_future)rrrZasync_futureZconc_future)r%rrr�wrapperxs
zCrun_on_executor.<locals>.run_on_executor_decorator.<locals>.wrapper)�get�	functools�wrapsrr)rr()r)r%rr�run_on_executor_decoratorusz2run_on_executor.<locals>.run_on_executor_decoratorz*cannot combine positional and keyword args�rzexpected 1 argument, got %d)rr�
ValueError�len)rrr,r)rr�run_on_executorJs+r0z
Future[_T])�a�brcsLddd���fdd�}t�t�r,t�|�nddlm}|j�j�|�dS)ajChain two futures together so that when one completes, so does the other.

    The result (success or failure) of ``a`` will be copied to ``b``, unless
    ``b`` has already been completed or cancelled by the time ``a`` finishes.

    .. versionchanged:: 5.0

       Now accepts both Tornado/asyncio `Future` objects and
       `concurrent.futures.Future`.

    z
Future[_T]N)r rcsl|�kst��j�rdSt�d�r>�j�dk	r>t��j��n*�j�dk	rZ�j�j��n�j�j��dS)Nr)	�AssertionError�done�hasattrrrZ	exception�
set_exception�
set_result�result)r )r1r2rr�copy�szchain_future.<locals>.copyr)�IOLoop)rr�future_add_done_callbackZtornado.ioloopr:ZcurrentZ
add_future)r1r2r9r:r)r1r2rr'�s


r'z%Union[futures.Future[_T], Future[_T]])r �valuercCs|j�s|j|�dS)z�Set the given ``value`` as the `Future`'s result, if not cancelled.

    Avoids ``asyncio.InvalidStateError`` when calling ``set_result()`` on
    a cancelled `asyncio.Future`.

    .. versionadded:: 5.0
    N)�	cancelledr7)r r<rrrr�s
r)r �excrcCs&|j�s|j|�ntjd|d�dS)a�Set the given ``exc`` as the `Future`'s exception.

    If the Future is already canceled, logs the exception instead. If
    this logging is not desired, the caller should explicitly check
    the state of the Future and call ``Future.set_exception`` instead of
    this wrapper.

    Avoids ``asyncio.InvalidStateError`` when calling ``set_exception()`` on
    a cancelled `asyncio.Future`.

    .. versionadded:: 6.0

    z$Exception after Future was cancelled)rN)r=r6r�error)r r>rrr�%future_set_exception_unless_cancelled�sr@)r rrcCs&|ddkrtd��t||d�dS)a�Set the given ``exc_info`` as the `Future`'s exception.

    Understands both `asyncio.Future` and the extensions in older
    versions of Tornado to enable better tracebacks on Python 2.

    .. versionadded:: 5.0

    .. versionchanged:: 6.0

       If the future is already cancelled, this function is a no-op.
       (previously ``asyncio.InvalidStateError`` would be raised)

    r-Nz,future_set_exc_info called with no exception)rr@)r rrrrr�srzfutures.Future[_T])r �callbackrcCsdS)Nr)r rArrrr;�sr;cCsdS)Nr)r rArrrr;�s.cCs |j�r||�n
|j|�dS)aLArrange to call ``callback`` when ``future`` is complete.

    ``callback`` is invoked with one argument, the ``future``.

    If ``future`` is already done, ``callback`` is invoked immediately.
    This may differ from the behavior of ``Future.add_done_callback``,
    which makes no such guarantee.

    .. versionadded:: 5.0
    N)r4Zadd_done_callback)r rArrrr;�s

).N)&�__doc__ZasyncioZ
concurrentrr*r�typesZtornado.logrZtypingrrrrrZTypeVarr	rr
rrr$rZExecutorrZdummy_executorr0�objectZ
_NO_RESULTr'r�
BaseExceptionr@�type�
TracebackTyperZoverloadr;rrrr�<module>sD

@"