Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
concurrent.cpython-313.pyc145 linesDownload Raw Back to __pycache__
1�

2��j�!��r�SrSSKrSSKJr SSKrSSKrSSKrSSKJr SSK	r	SSK	J3r4JrJrJ
r
Jr \	R"S5r"SS\5r\R&r\R&\4rS	\5S6\4Sjr"SS
\R.5r\"5rS\7S\8S9\4Sjr\"5rS\SS\SS10S4SjrSSS\S11S4SjrSSS\S12S4Sjr SSS\
\\!\\\\RD4S13S4Sjr#\	RHSSS\S/S4S14S4Sj5r%\	RHSS S\S /S4S15S4S!j5r%SSS\S"S16S4S#jr%g)$a�Utilities for working with ``Future`` objects.17 18Tornado previously provided its own ``Future`` class, but now uses19`asyncio.Future`. This module contains utility functions for working20with `asyncio.Future` in a way that is backwards-compatible with21Tornado's old ``Future`` implementation.22 23While this module is an important part of Tornado's internal24implementation, applications rarely need to interact with it25directly.26 27�N)�futures)�app_log)�Any�Callable�Optional�Tuple�Union�_Tc��\rSrSrSrg)�ReturnValueIgnoredError�*�N)�__name__�28__module__�__qualname__�__firstlineno__�__static_attributes__r��XD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/concurrent.pyrr*s��rr�x�returnc�"�[U[5$�N)�29isinstance�FUTURES)rs r�	is_futurer4s���a��!�!rc��\rSrSrS\S\4S\S\SS4Sjr\RS	:�aSS30\31S\32SS4S
jjrSrgSS33\34SS4SjjrSrg)�
DummyExecutor�8�fn.�args�kwargsr�futures.Future[_T]c��[R"5n[XA"U0UD65 U$![a# [	U[35R"55 U$f=fr)r�Future�"future_set_result_unless_cancelled�	Exception�future_set_exc_info�sys�exc_info)�selfr r!r"�futures     r�submit�DummyExecutor.submit9sV�����!��	8�.�v�r�4�7J�6�7J�K��
���	8�������7��
�	8�s�*�)A�A)��	�wait�cancel_futuresNc��grr)r+r1r2s   r�shutdown�DummyExecutor.shutdownE���rc��grr)r+r1s  rr4r5Jr6rr)TF)T)
rrrrrr36rr-r)�version_info�boolr4rrrrrr8sw����3��7�#��,/��;>��	�����6�!�	��	�d�	�t�	�	�37	��	��	�	rrr!r"c��^�S[S[S[44U4SjjnU(aT(a[S5e[U5S:XaU"US5$[U5S:wa[S[U55eU$)	a�Decorator to run a synchronous method asynchronously on an executor.38 39Returns a future.40 41The executor to be used is determined by the ``executor``42attributes of ``self``. To use a different attribute name, pass a43keyword argument to the decorator::44 45    @run_on_executor(executor='_thread_pool')46    def foo(self):47        pass48 49This decorator should not be confused with the similarly-named50`.IOLoop.run_in_executor`. In general, using ``run_in_executor``51when *calling* a blocking method is recommended instead of using52this decorator when *defining* a method. If compatibility with older53versions of Tornado is required, consider defining an executor54and using ``executor.submit()`` at the call site.55 56.. versionchanged:: 4.257   Added keyword arguments to use alternative attributes.58 59.. versionchanged:: 5.060   Always uses the current IOLoop instead of ``self.io_loop``.61 62.. versionchanged:: 5.163   Returns a `.Future` compatible with ``await`` instead of a64   `concurrent.futures.Future`.65 66.. deprecated:: 5.167 68   The ``callback`` argument is deprecated and will be removed in69   6.0. The decorator itself is discouraged in new code but will70   not be removed in 6.0.71 72.. versionchanged:: 6.073 74   The ``callback`` argument was removed.75r r.c	�>^^�TRSS5m[R"T5S[S[S[S[4UU4Sjj5nU$)N�executorr+r!r"rc�t>�[5n[UT5R"TU/UQ70UD6n[XC5 U$r)r%�getattrr-�chain_future)r+r!r"�async_future�conc_futurer<r s     ��r�wrapper�Crun_on_executor.<locals>.run_on_executor_decorator.<locals>.wrappers;���!�8�L�!�$��1�8�8��T�S�D�S�F�S�K���3��r)�get�	functools�wrapsrr%)r rBr<r"s` @�r�run_on_executor_decorator�2run_on_executor.<locals>.run_on_executor_decorator|sQ����:�:�j�*�5��	����	�	 �#�	 �c�	 �S�	 �V�	 �76�	 ��rz*cannot combine positional and keyword args�rzexpected 1 argument, got %d)rr%�77ValueError�len)r!r"rGs ` r�run_on_executorrLQsp���V78�h�79�8�C��K�3H�80����E�F�F�81�4�y�A�~�(��a��1�1�	�T��a���6��D�	�B�B�$�$r�a)�82Future[_T]r#�bc�^�SU4Sjjn[U[5(a[X5 gSSKJn UR5R
X5 g)aRChain two futures together so that when one completes, so does the other.83 84The result (success or failure) of ``a`` will be copied to ``b``, unless85``b`` has already been completed or cancelled by the time ``a`` finishes.86 87.. versionchanged:: 5.088 89   Now accepts both Tornado/asyncio `Future` objects and90   `concurrent.futures.Future`.91 92Nc�4>�TR5(ag[US5(a,UR5b[TUR55 gUR	5nUbTRU5 gTR
UR55 g)Nr*)�done�hasattrr*r(�	exception�
set_exception�93set_result�result)rM�a_excrOs  �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�(rr)�IOLoop)rMrNrN)rr%�future_add_done_callback�tornado.ioloopr[�current�94add_future)rMrOrYr[s `  rr?r?�s9��� 95)��!�V��� ��)�	*�����#�#�A�,rr,z%Union[futures.Future[_T], Future[_T]]�valuec�R�UR5(dURU5 gg)z�Set the given ``value`` as the `Future`'s result, if not cancelled.96 97Avoids ``asyncio.InvalidStateError`` when calling ``set_result()`` on98a cancelled `asyncio.Future`.99 100.. versionadded:: 5.0101N)�	cancelledrV)r,r`s  rr&r&�s&����������%� �r�excc�|�UR5(dURU5 g[R"SUS9 g)a�Set the given ``exc`` as the `Future`'s exception.102 103If the Future is already canceled, logs the exception instead. If104this logging is not desired, the caller should explicitly check105the state of the Future and call ``Future.set_exception`` instead of106this wrapper.107 108Avoids ``asyncio.InvalidStateError`` when calling ``set_exception()`` on109a cancelled `asyncio.Future`.110 111.. versionadded:: 6.0112 113z$Exception after Future was cancelled)r*N)rbrUr�error)r,rcs  r�%future_set_exception_unless_cancelledrf�s0�� ��������S�!��
�
�<�s�Krr*c�B�USc[S5e[XS5 g)aeSet the given ``exc_info`` as the `Future`'s exception.114 115Understands both `asyncio.Future` and the extensions in older116versions of Tornado to enable better tracebacks on Python 2.117 118.. versionadded:: 5.0119 120.. versionchanged:: 6.0121 122   If the future is already cancelled, this function is a no-op.123   (previously ``asyncio.InvalidStateError`` would be raised)124 125rINz,future_set_exc_info called with no exception)r'rf)r,r*s  rr(r(�s&��&��{���F�G�G�)�&�1�+�>rr#�callbackc��grr�r,rhs  rr\r\����	rrNc��grrrjs  rr\r\�rkr).Nc�b�UR5(a	U"U5 gURU5 g)a4Arrange to call ``callback`` when ``future`` is complete.126 127``callback`` is invoked with one argument, the ``future``.128 129If ``future`` is already done, ``callback`` is invoked immediately.130This may differ from the behavior of ``Future.add_done_callback``,131which makes no such guarantee.132 133.. versionadded:: 5.0134N)rR�add_done_callbackrjs  rr\r\s%���{�{�}�}����� � ��*r)&�__doc__�asyncio�135concurrentrrEr)�types�tornado.logr�typingrrrrr	�TypeVarr136r'rr%rr9r�Executorr�dummy_executorrL�object�137_NO_RESULTr?r&�
BaseExceptionrf�type�
TracebackTyper(�overloadr\rrr�<module>r~s�������138���
�8�8��^�^�D���	�i�	�139140�����>�>�6�141"��"��"��"��G�$�$��,���=%�3�=%�#�=%�(�=%�@�X�142�"-��
/�0�"-��
/�0�"-�143�"-�J!�3�!�<>�!�	�!�L�3�L�:G�L�	�L�,?�3�?�������/��%�:M�:M�1N�N��?�144145�?�0���	� �	�,4�6J�5K�T�5Q�,R�	�	�	��	����	��	�$,�l�^�T�-A�$B�	�	�	��	�+�3�+�?G�	�?R�+�	�+r
codekingpro/portable-devtools · Team Ai