+
    ‚V@i¸   ã                   óÂ  € R t ^ RIt^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RI	t	^ RI	H
t
HtHtHtHt ]	P                  ! R4      t ! R R]4      t]P&                  t]P&                  ]3tR R	 lt ! R
 R]P,                  4      t]! 4       tR R lt]! 4       tR R ltR R ltR R ltR R lt]	P@                  R R l4       t!]	P@                  R R l4       t!R R lt!R# )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                   ó   € ] tR t^*tRtR# )ÚReturnValueIgnoredError© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Ú4/usr/lib/python3/dist-packages/tornado/concurrent.pyr   r   *   s   † ãr   r   c                ó0   € V ^8„  d   QhR\         R\        /# )é   ÚxÚreturn)r   Úbool)Úformats   "r   Ú__annotate__r   4   s   € ÷ "ñ "”ð "œñ "r   c                 ó"   € \        V \        4      # ©N)Ú
isinstanceÚFUTURES)r   s   &r   Ú	is_futurer   4   s   € Ü�aœÓ!Ð!r   c                   óŒ   a € ] tR t^8t o V 3R lR lt]P                  R	8¼  d   R
V 3R lR lltRtV t	R# RV 3R lR lltRtV t	R# )ÚDummyExecutorc                óD   <€ V ^8„  d   QhRS[ RS[3,          RS[RS[RR/# )r   Úfn.ÚargsÚkwargsr   úfutures.Future[_T])r   r	   r   )r   Ú__classdict__s   "€r   r   ÚDummyExecutor.__annotate__9   s6   ø€ ÷ ñ Ù˜3¡˜7Õ#ðÙ,/ðÙ;>ðà	ñr   c                ó¶   € \         P                  ! 4       p \        WA! V/ VB 4       V#   \         d$    \	        T\
        P                  ! 4       4        T# i ; ir   )r   ÚFutureÚ"future_set_result_unless_cancelledÚ	ExceptionÚfuture_set_exc_infoÚsysÚexc_info)Úselfr#   r$   r%   Úfutures   &&*, r   ÚsubmitÚDummyExecutor.submit9   sV   € ô —’Ó!ˆð	8Ü.¨v°r¸4Ð7JÀ6Ñ7JÔKð ˆøô ô 	8Ü ¬¯ª«Õ7Øˆð	8ús   —* ª*AÁAc                ó*   <€ V ^8„  d   QhRS[ RS[ RR/# )r   ÚwaitÚcancel_futuresr   N©r   )r   r'   s   "€r   r   r(   E   s"   ø€ ÷ 	ñ 	¡ð 	¹dð 	Ètñ 	r   c                ó   € R # r   r   )r0   r5   r6   s   &&&r   ÚshutdownÚDummyExecutor.shutdownE   ó   € Ùr   c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   r5   r   Nr7   )r   r'   s   "€r   r   r(   J   s   ø€ ÷ 	ñ 	¡ð 	°ñ 	r   c                ó   € R # r   r   )r0   r5   s   &&r   r9   r:   J   r;   r   r   N)é   é	   )TF)T)
r   r   r   r   r2   r.   Úversion_infor9   r   Ú__classdictcell__)r'   s   @r   r!   r!   8   s=   ø‡ € ÷ð ð ×Ñ˜6Ô!÷	÷ 	ð 	÷
	÷ 	ð 	r   r!   c                ó<   € V ^8„  d   QhR\         R\         R\        /# )r   r$   r%   r   )r   r   )r   s   "r   r   r   Q   s!   € ÷ =%ñ =%œ3ð =%¬#ð =%´(ñ =%r   c                 óØ   a€ R V3R llpV '       d   S'       d   \        R4      h\        V 4      ^8X  d   V! V ^ ,          4      # \        V 4      ^ 8w  d   \        R\        V 4      4      hV# )aÙ  Decorator to run a synchronous method asynchronously on an executor.

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.
c                óJ   € V ^8„  d   QhR\         R\         R\        3,          /# )r   r#   r   .)r   r*   )r   s   "r   r   Ú%run_on_executor.<locals>.__annotate__|   s#   € ÷ 
ñ 
¤hð 
´8¸CÄ¸KÕ3Hñ 
r   c                 óv   <a a€ SP                  R R 4      o\        P                  ! S 4      R VV 3R ll4       pV# )Úexecutorc                óH   € V ^8„  d   QhR\         R\         R\         R\        /# )r   r0   r$   r%   r   )r   r*   )r   s   "r   r   ÚHrun_on_executor.<locals>.run_on_executor_decorator.<locals>.__annotate__€   s(   € ÷ 	 ñ 	 œ#ð 	 ¤cð 	 ´Sð 	 ¼Vñ 	 r   c                 ót   <€ \        4       p\        V S4      P                  ! SV .VO5/ VB p\        WC4       V# r   )r*   Úgetattrr2   Úchain_future)r0   r$   r%   Úasync_futureÚconc_futurerG   r#   s   &*,  €€r   ÚwrapperÚCrun_on_executor.<locals>.run_on_executor_decorator.<locals>.wrapper   s;   ø€ ä!›8ˆLÜ! $¨Ó1×8Ò8¸¸TÐSÀDÒSÈFÑSˆKÜ˜Ô3ØÐr   )ÚgetÚ	functoolsÚwraps)r#   rO   rG   r%   s   f @€r   Úrun_on_executor_decoratorÚ2run_on_executor.<locals>.run_on_executor_decorator|   s:   ú€ Ø—:‘:˜j¨*Ó5ˆä	�Š˜Ó	÷	 ð 	 ó 
ð	 ð ˆr   z*cannot combine positional and keyword argszexpected 1 argument, got %d)Ú
ValueErrorÚlen)r$   r%   rT   s   *l r   Úrun_on_executorrX   Q   s^   ø€ ÷V
ð 
÷ —ÜÐEÓFÐFÜ
ˆ4ƒy�A„~Ù(¨¨a­Ó1Ð1Ü	ˆT‹�aŒÜÐ6¼¸D»	ÓBÐBØ$Ð$r   c                óP   € V ^8„  d   QhR\         R,          R\         R,          RR/# )r   ÚaÚbr   N)ú
Future[_T]r&   )r   )r   s   "r   r   r   ”   s2   € ÷ "-ñ "-ÜÐ/Õ0ð"-äÐ/Õ0ð"-ð 
ñ"-r   c                óª   a€ R V3R llp\        V \        4      '       d   \        W4       R# ^ RIHp VP                  4       P                  W4       R# )aR  Chain 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`.

c                ó    € V ^8„  d   QhRRRR/# )r   rZ   r\   r   Nr   )r   s   "r   r   Ú"chain_future.<locals>.__annotate__¤   s   € ÷ 
)ñ 
)�ð 
) ñ 
)r   c                 óD  <€ SP                  4       '       d   R # \        V R4      '       d/   V P                  4       e   \        SV P                  4       4       R # V P	                  4       pVe   SP                  V4       R # SP                  V P                  4       4       R # )Nr/   )ÚdoneÚhasattrr/   r-   Ú	exceptionÚset_exceptionÚ
set_resultÚresult)rZ   Úa_excr[   s   & €r   ÚcopyÚchain_future.<locals>.copy¤   sh   ø€ Ø�6‰6�8Š8ÙÜ�1�j×!Ò! a§j¡j£lÒ&>Ü  1§:¡:£<Ö0à—K‘K“MˆEØÒ Ø—‘ Ö&à—‘˜QŸX™X›ZÖ(r   )ÚIOLoopN)r   r*   Úfuture_add_done_callbackÚtornado.iolooprj   ÚcurrentÚ
add_future)rZ   r[   rh   rj   s   &f  r   rL   rL   ”   s>   ø€ ÷ 
)ð 
)ô �!”V×ÒÜ  Ö)õ 	*à�‰Ó×#Ñ# AÖ,r   c                ó,   € V ^8„  d   QhRRR\         RR/# )r   r1   ú%Union[futures.Future[_T], Future[_T]]Úvaluer   N)r	   )r   s   "r   r   r   ¹   s$   € ÷ !ñ !Ø3ð!Ü<>ð!à	ñ!r   c                óX   € V P                  4       '       g   V P                  V4       R# R# )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)Ú	cancelledre   )r1   rq   s   &&r   r+   r+   ¹   s&   € ð ×Ñ×ÒØ×Ñ˜%Ö ñ r   c                ó,   € V ^8„  d   QhRRR\         RR/# )r   r1   rp   Úexcr   N)ÚBaseException)r   s   "r   r   r   Ç   s)   € ÷ Lñ LØ3ðLÜ:GðLà	ñLr   c                óˆ   € V P                  4       '       g   V P                  V4       R# \        P                  ! RVR7       R# )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)r/   N)rs   rd   r   Úerror)r1   ru   s   &&r   Ú%future_set_exception_unless_cancelledry   Ç   s0   € ð  ×Ñ×ÒØ×Ñ˜SÖ!ä�ŠÐ<Às×Kr   c                ó®   € V ^8„  d   QhRRR\         \        \        ,          \        \        ,          \        \        P
                  ,          3,          RR/# )r   r1   rp   r/   r   N)r   r   Útyperv   ÚtypesÚTracebackType)r   s   "r   r   r   Ý   sI   € ÷ ?ñ ?Ø3ð?äÜ”�œ¤Õ/´¼%×:MÑ:MÕ1NÐNõð?ð
 
ñ?r   c                óV   € V^,          f   \        R4      h\        W^,          4       R# )ae  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)

Nz,future_set_exc_info called with no exception)r,   ry   )r1   r/   s   &&r   r-   r-   Ý   s&   € ð& �…{ÒÜÐFÓGÐGÜ)¨&¸1µ+Ö>r   c                ó@   € V ^8„  d   QhRRR\         R.R3,          RR/# )r   r1   r&   ÚcallbackNr   ©r   )r   s   "r   r   r   ö   s2   € ÷ 	ñ 	Ø ð	Ü,4Ð6JÐ5KÈTÐ5QÕ,Rð	à	ñ	r   c                 ó   € R # r   r   ©r1   r€   s   &&r   rk   rk   õ   ó   € ñ 	r   c                ó@   € V ^8„  d   QhRRR\         R.R3,          RR/# )r   r1   r\   r€   Nr   r�   )r   s   "r   r   r   ý   s0   € ÷ 	ñ 	Øð	Ü$,¨l¨^¸TÐ-AÕ$Bð	à	ñ	r   c                 ó   € R # r   r   rƒ   s   &&r   rk   rk   ü   r„   r   c                ó:   € V ^8„  d   QhRRR\         R,          RR/# )r   r1   rp   r€   Nr   ).Nr�   )r   s   "r   r   r     s)   € ÷ +ñ +Ø3ð+Ü?GÈ	Õ?Rð+à	ñ+r   c                óh   € V P                  4       '       d   V! V 4       R# V P                  V4       R# )a4  Arrange 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)ra   Úadd_done_callbackrƒ   s   &&r   rk   rk     s%   € ð ‡{�{‡}‚}Ù�Öà× Ñ  Ö*r   )"Ú__doc__ÚasyncioÚ
concurrentr   rR   r.   r|   Útornado.logr   Útypingr   r   r   r   r   ÚTypeVarr	   r,   r   r*   r   r   ÚExecutorr!   Údummy_executorrX   ÚobjectÚ
_NO_RESULTrL   r+   ry   r-   Úoverloadrk   r   r   r   Ú<module>r•      sÔ   ðñó Ý Û Û 
Û å ã ß 8Õ 8à‡^‚^�DÓ€ô	˜iô 	ð
 
�‰€à�>‰>˜6Ð
"€õ"ô�G×$Ñ$ô ñ, “€õ=%ñ@ ‹X€
õ"-õJ!õLõ,?ð0 ‡�ô	ó ð	ð ‡�ô	ó ð	÷+r   