AlkantarClanX12

Your IP : 18.220.242.160


Current Path : /opt/alt/python312/lib64/python3.12/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/asyncio/__pycache__/tasks.cpython-312.opt-1.pyc

�

�Q�f����dZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZej&d�j(Zd/d�Zd/d
�Zd�ZGd�dej2�ZeZ	ddlZej4xZZddd�d�Zej"j@Z ej"jBZ!ej"jDZ"de"d�d�Z#d�Z$d�Z%d�Z&d�Z'dd�d�Z(ejRd��Z*d/d�Z+dd�d�Z,Gd�d ejZ�Z.d!d"�d#�Z/d$�Z0d%�Z1d&�Z2e2e�Z3e
jh�Z5e6�Z7iZ8d'�Z9d(�Z:d)�Z;d*�Z<d+�Z=d,�Z>d-�Z?eZ@e9ZAe:ZBe>ZCe?ZDe;ZEe<ZFe=ZG	dd.lm9Z9m:Z:m>Z>m?Z?m;Z;m<Z<m=Z=m5Z5m7Z7m8Z8mZeZHe9ZIe:ZJe>ZKe?ZLe;ZMe<ZNe=ZOy#e$rY��wxYw#e$rYywxYw)0z0Support for tasks, coroutines and the scheduler.)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield�
ensure_future�run_coroutine_threadsafe�current_task�	all_tasks�create_eager_task_factory�eager_task_factory�_register_task�_unregister_task�_enter_task�_leave_task�N)�GenericAlias�)�
base_tasks)�
coroutines)�events)�
exceptions)�futures)�timeoutsc�X�|�tj�}tj|�S)z!Return a currently executed task.)r�get_running_loop�_current_tasks�get��loops �4/opt/alt/python312/lib64/python3.12/asyncio/tasks.pyrr$s&���|��&�&�(�����d�#�#�c�N�|�tj�}tt�}d}d}		tt�}	t
j||�D�chc]+}tj|�|ur|j�s|��-c}S#t
$r|dz
}|dk\r�YnwxYw�wcc}w)z'Return a set of all tasks for the loop.Nrri�)rr!�list�_eager_tasks�_scheduled_tasks�RuntimeError�	itertools�chainr�	_get_loop�done)r%�eager_tasks�scheduled_tasks�i�ts     r&rr+s����|��&�&�(���|�$�K��O�	�A�
�	�"�#3�4�O�
� �����D�>�D�!�� � ��#�t�+�A�F�F�H�
�D�>�>��
�	�
��F�A��D�y���	����>s�B�0B"�B�Bc��|�	|j}||�yy#t$rtjdtd��YywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.�)�
stacklevel)�set_name�AttributeError�warnings�warn�DeprecationWarning)�task�namer8s   r&�_set_task_namer?FsM����	��}�}�H�
�T�N����	8��M�M�9�)�Q�
8�	8�s��%A�Ac����eZdZdZdZddddd��fd�
Z�fd�Zee�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zdd�d�Zddd�d�Zdd�Zd�Zd�Zd�Zdd�Z�fd�Zd�Z�xZS)rz A coroutine wrapped in a Future.TNF�r%r>�context�eager_startc�F��t�|�|��|jr
|jd=tj|�sd|_t
d|����|�dt���|_nt|�|_d|_
d|_d|_||_
|�tj�|_n||_|r+|j"j%�r|j'�y|j"j)|j*|j ��t-|�y)Nr$���Fza coroutine was expected, got zTask-r�rB)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending�	TypeError�_task_name_counter�_name�str�_num_cancels_requested�_must_cancel�_fut_waiter�_coro�contextvars�copy_context�_context�_loop�
is_running�_Task__eager_start�	call_soon�_Task__stepr)�self�coror%r>rBrC�	__class__s      �r&rHz
Task.__init__os����
���d��#��!�!��&�&�r�*��%�%�d�+�).�D�%��<�T�H�E�F�F��<� �!3�!5� 6�7�D�J��T��D�J�&'��#�!��������
��?�'�4�4�6�D�M�#�D�M��4�:�:�0�0�2���� ��J�J� � ����d�m�m� �D��4� r'c����|jtjk(rG|jr;|dd�}|jr|j|d<|j
j
|�t�|�!�y)Nz%Task was destroyed but it is pending!)r=�message�source_traceback)	�_stater�_PENDINGrKrIrW�call_exception_handlerrG�__del__)r\rBr^s  �r&rezTask.__del__�sb����;�;�'�*�*�*�t�/H�/H��B��G��%�%�.2�.D�.D��*�+��J�J�-�-�g�6�
���r'c�,�tj|�S�N)r�
_task_repr�r\s r&�__repr__z
Task.__repr__�s���$�$�T�*�*r'c��|jSrg)rSris r&�get_coroz
Task.get_coro�����z�z�r'c��|jSrg)rVris r&�get_contextzTask.get_context�s���}�}�r'c��|jSrg)rNris r&�get_namez
Task.get_name�rmr'c�$�t|�|_yrg)rOrN)r\�values  r&r8z
Task.set_name�s
����Z��
r'c��td��)Nz*Task does not support set_result operation�r,)r\�results  r&�
set_resultzTask.set_result�s���G�H�Hr'c��td��)Nz-Task does not support set_exception operationru)r\�	exceptions  r&�
set_exceptionzTask.set_exception�s���J�K�Kr')�limitc�.�tj||�S)a�Return the list of stack frames for this task's coroutine.

        If the coroutine is not done, this returns the stack where it is
        suspended.  If the coroutine has completed successfully or was
        cancelled, this returns an empty list.  If the coroutine was
        terminated by an exception, this returns the list of traceback
        frames.

        The frames are always ordered from oldest to newest.

        The optional limit gives the maximum number of frames to
        return; by default all available frames are returned.  Its
        meaning differs depending on whether a stack or a traceback is
        returned: the newest frames of a stack are returned, but the
        oldest frames of a traceback are returned.  (This matches the
        behavior of the traceback module.)

        For reasons beyond our control, only one stack frame is
        returned for a suspended coroutine.
        )r�_task_get_stack)r\r{s  r&�	get_stackzTask.get_stack�s��*�)�)�$��6�6r')r{�filec�0�tj|||�S)anPrint the stack or traceback for this task's coroutine.

        This produces output similar to that of the traceback module,
        for the frames retrieved by get_stack().  The limit argument
        is passed to get_stack().  The file argument is an I/O stream
        to which the output is written; by default output is written
        to sys.stderr.
        )r�_task_print_stack)r\r{rs   r&�print_stackzTask.print_stack�s���+�+�D�%��>�>r'c���d|_|j�ry|xjdz
c_|j�|jj	|��ryd|_||_y)a�Request that this task cancel itself.

        This arranges for a CancelledError to be thrown into the
        wrapped coroutine on the next cycle through the event loop.
        The coroutine then has a chance to clean up or even deny
        the request using try/except/finally.

        Unlike Future.cancel, this does not guarantee that the
        task will be cancelled: the exception might be caught and
        acted upon, delaying cancellation of the task or preventing
        cancellation completely.  The task may also return a value or
        raise a different exception.

        Immediately after this method is called, Task.cancelled() will
        not return True (unless the task was already cancelled).  A
        task will be marked as cancelled when the wrapped coroutine
        terminates with a CancelledError exception (even if cancel()
        was not called).

        This also increases the task's count of cancellation requests.
        Fr��msgT)�_log_tracebackr0rPrR�cancelrQ�_cancel_message)r\r�s  r&r�zTask.cancel�sf��,$����9�9�;���#�#�q�(�#����'����&�&�3�&�/�� ���"���r'c��|jS)z�Return the count of the task's cancellation requests.

        This count is incremented when .cancel() is called
        and may be decremented using .uncancel().
        �rPris r&�
cancellingzTask.cancelling�s���*�*�*r'c�b�|jdkDr|xjdzc_|jS)z�Decrement the task's count of cancellation requests.

        This should be called by the party that called `cancel()` on the task
        beforehand.

        Returns the remaining number of cancellation requests.
        rrr�ris r&�uncancelz
Task.uncancels/���&�&��*��'�'�1�,�'��*�*�*r'c�p�t|j|�}	t|�	|jj	|j
d�t
|�		t|j|�}|j�r
d|_d}yt|�y#t
|�wxYw#|j�r
d|_d}wt|�wxYw#	t|j|�}|j�r
d|_d}wt|�w#|j�r
d|_d}wt|�wxYwxYwrg)
�_swap_current_taskrW�_register_eager_taskrV�run�!_Task__step_run_and_handle_result�_unregister_eager_taskr0rSr)r\�	prev_task�curtasks   r&�
__eager_startzTask.__eager_starts���&�t�z�z�4�8�	�	)� ��&�
-��
�
�!�!�$�"C�"C�T�J�&�t�,�
)�,�T�Z�Z��C���9�9�;�!%�D�J��D�"�4�(��'�t�,���9�9�;�!%�D�J��D�"�4�(��
)�,�T�Z�Z��C���9�9�;�!%�D�J��D�"�4�(��	�9�9�;�!%�D�J��D�"�4�(�sF�C
�&B�
C
�B#�
B � C
�#'C
�
D5�D�%&D5�'D2�2D5c��|j�rtjd|�d|����|jr1t	|tj
�s|j
�}d|_d|_t|j|�	|j|�t|j|�d}y#t|j|�d}wxYw)Nz_step(): already done: z, F)r0r�InvalidStateErrorrQ�
isinstance�CancelledError�_make_cancelled_errorrRrrWr�r)r\�excs  r&�__stepzTask.__step#s����9�9�;��.�.�)�$���C�7�;�=�
=�����c�:�#<�#<�=��0�0�2�� %�D������D�J�J��%�	��-�-�c�2���
�
�D�)��D��
��
�
�D�)��D�s�B1�1Cc����|j}	|�|jd�}n|j|�}t|dd�}|��lt	j
|�|jurGtd|�d|�d��}|jj|j||j��d}y|r�||urCtd|���}|jj|j||j��d}yd|_|j|j|j��||_|j�rN|jj!|j"���r'd|_	d}ytd	|�d
|���}|jj|j||j��	d}y|�4|jj|j|j��d}yt%j&|�rFtd|�d
|���}|jj|j||j��d}ytd|���}|jj|j||j��	d}yd}y#t($rS}|jr"d|_t*�|�A|j"��nt*�|�Y|j.�Yd}~d}yd}~wt0j2$r!}||_t*�|�A�Yd}~d}yd}~wt6t8f$r}t*�|�u|��d}~wt<$r}t*�|�u|�Yd}~d}yd}~wwxYw#d}wxYw)
N�_asyncio_future_blockingzTask z got Future z attached to a different looprFzTask cannot await on itself: Fr�z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rS�send�throw�getattrrr/rWr,rZr[rVr��add_done_callback�
_Task__wakeuprRrQr�r��inspect�isgenerator�
StopIterationrGrwrsrr��_cancelled_exc�KeyboardInterrupt�
SystemExitrz�
BaseException)r\r�r]rv�blocking�new_excr^s      �r&�__step_run_and_handle_resultz!Task.__step_run_and_handle_result4se����z�z��G	��{����4������C���$�v�'A�4�H�H��#��$�$�V�,�D�J�J�>�*���x�|�!�*�$A�C�D�G��J�J�(�(����W�d�m�m�)�E�P�D�M���~�".�;�D�8�D�#F���
�
�,�,� �K�K��$�-�-�-�I�D�D�?;@��7��0�0� �M�M�4�=�=�1�B�+1��(��,�,�#�/�/�6�6�(,�(<�(<� 7� >�49�� 1�0�D�-+�#�#'�(�&��
�<�=�G��J�J�(�(����W�d�m�m�)�E�&�D�!���
�
�$�$�T�[�[�$�-�-�$�H��D��$�$�V�,�&�)�)-���v�j�B�C���
�
�$�$��K�K��$�-�-�%�A��D�	'�)=�f�Z�'H�I���
�
�$�$��K�K��$�-�-�%�A��D�4�D��A�	.�� � �$)��!����4�#7�#7��8���"�3�9�9�-��t�D��s�(�(�	�"%�D���G�N���l�D��k"�:�.�	��G�!�#�&����	'��G�!�#�&�&�b�D��e	'��d�D�s��%J�A5M�,AM�5A0M�)AM�03M�&AM�AM�	M�AK�M�M�5L�
M�M�#L3�3M�?M�M�M�M�M!c��	|j�|j�d}y#t$r}|j|�Yd}~d}yd}~wwxYwrg)rvr[r�)r\�futurer�s   r&�__wakeupz
Task.__wakeupsH��	��M�M�O�
�K�K�M�����	��K�K�������	�s�%�	A�A�Arg)�__name__�
__module__�__qualname__�__doc__rKrHre�classmethodr�__class_getitem__rjrlrorqr8rwrzr~r�r�r�r�rYr[r�r��
__classcell__�r^s@r&rrSs����+�. ��%)��d�"�!�>	�$�L�1��+���� �I�L�"&�7�.$(�d�	?�(�T+�
+�)�&�"I�Vr'r�r>rBc��tj�}|�|j|�}n|j||��}t||�|S)z]Schedule the execution of a coroutine object in a spawn task.

    Return a Task object.
    rF)rr!rr?)r]r>rBr%r=s     r&rr�sK��
�"�"�$�D�������%������g��6���4����Kr')�timeout�return_whenc��K�tj|�stj|�r!t	dt|�j����|std��|tttfvrtd|����t|�}td�|D��rt	d��tj�}t||||��d{���S7��w)a}Wait for the Futures or Tasks given by fs to complete.

    The fs iterable must not be empty.

    Coroutines will be wrapped in Tasks.

    Returns two sets of Future: (done, pending).

    Usage:

        done, pending = await asyncio.wait(fs)

    Note: This does not raise TimeoutError! Futures that aren't done
    when the timeout occurs are returned in the second set.
    zexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3�FK�|]}tj|����y�wrg)rrJ)�.0�fs  r&�	<genexpr>zwait.<locals>.<genexpr>�s����
1�b��:�!�!�!�$�b�s�!z6Passing coroutines is forbidden, use tasks explicitly.N)r�isfuturerrJrL�typer��
ValueErrorrrr�set�anyrr!�_wait)�fsr�r�r%s    r&rr�s����� �����z�5�5�b�9��8��b��9J�9J�8K�L�M�M�
��9�:�:��?�O�]�K�K��6�{�m�D�E�E�	�R��B�
�
1�b�
1�1��P�Q�Q��"�"�$�D��r�7�K��6�6�6�6�s�CC�	C�
Cc�H�|j�s|jd�yyrg)r0rw)�waiter�argss  r&�_release_waiterr��s���;�;�=����$��r'c��K�|�T|dkrOt|�}|j�r|j�St|��d{���	|j�Stj|�4�d{���|�d{���cddd��d{���S7�N#tj
$r}t|�d}~wwxYw7�C7�;7�-#1�d{���7swYyxYw�w)a�Wait for the single Future or coroutine to complete, with timeout.

    Coroutine will be wrapped in Task.

    Returns result of the Future or coroutine.  When a timeout occurs,
    it cancels the task and raises TimeoutError.  To avoid the task
    cancellation, wrap it in shield().

    If the wait is cancelled, the task is also cancelled.

    If the task suppresses the cancellation and returns a value instead,
    that value is returned.

    This function is a coroutine.
    Nr)	r
r0rv�_cancel_and_waitrr��TimeoutErrorrr�)�futr�r�s   r&rr�s�����F��w�!�|��C� ���8�8�:��:�:�<���s�#�#�#�	(��:�:�<������(�(��y����
	$���(�(�	(��C�'��	(��)������(�(�(�s��AC�B�C�	B�C�2B6�3C�6B<�<B8�=B<�C�B:�
C�B3�'B.�.B3�3C�8B<�:C�<C�C�C�
Cc��0���	�
K�|j��
d�	|�|j|t�
��	t|�����	�
fd�}|D]}|j	|��	�
�d{����	��	j�|D]}|j
|��	t�t�}}|D]5}|j�r|j|��%|j|��7||fS7��#�	��	j�|D]}|j
|��wxYw�w)zVInternal helper for wait().

    The fs argument must be a collection of Futures.
    Nc�����dz��dks2�tk(s)�tk(rW|j�sF|j��5���j	��j�s�j
d�yyyyy)Nrr)rr�	cancelledryr�r0rw)r��counterr��timeout_handler�s ����r&�_on_completionz_wait.<locals>._on_completionst����1����q�L��?�*��?�*�A�K�K�M�01���
�0I��)��%�%�'��;�;�=��!�!�$�'�!�1J�5B�*r')
�
create_future�
call_laterr��lenr�r��remove_done_callbackr�r0�add)r�r�r�r%r�r�r0�pendingr�r�r�s  `     @@@r&r�r�
s������
�
�
!�F��N�������/�6�J���"�g�G�
(���	���N�+��3�����%��!�!�#��A�
�"�"�>�2���E�3�5�'�D�
���6�6�8��H�H�Q�K��K�K��N�	�
��=��	���%��!�!�#��A�
�"�"�>�2��s1�AD�C'�#C%�$C'�(A=D�%C'�',D�Dc��2K�tj�}|j�}tjt
|�}|j
|�	|j�|�d{���|j|�y7�#|j|�wxYw�w)z<Cancel the *fut* future or task and wait until it completes.N)	rr!r��	functools�partialr�r�r�r�)r�r%r��cbs    r&r�r�6s}�����"�"�$�D�
�
�
�
!�F�	�	�	�?�F�	3�B����"��%��
�
������ � ��$�	��� � ��$�s0�AB�B�(A?�)B�-B�?B�B�B)r�c#���	�
�K�tj|�stj|�r!t	dt|�j����ddlm}|��	tj�}t|�D�chc]}t||����c}�d�
��	�fd�}�	�
�fd���	fd�}�D]}|j����r|�|j||��
tt!���D]}|����
ycc}w�w)	a^Return an iterator whose values are coroutines.

    When waiting for the yielded coroutines you'll get the results (or
    exceptions!) of the original Futures (or coroutines), in the order
    in which and as soon as they complete.

    This differs from PEP 3148; the proper way to use this is:

        for f in as_completed(fs):
            result = await f  # The 'await' may raise.
            # Use result.

    If a timeout is specified, the 'await' will raise
    TimeoutError when the timeout occurs before all Futures are done.

    Note: The futures 'f' are not necessarily members of fs.
    z#expect an iterable of futures, not r)�Queuer$Nc�x���D]$}|j���jd��&�j�yrg)r��
put_nowait�clear)r�r�r0�todos ���r&�_on_timeoutz!as_completed.<locals>._on_timeoutds2����A�
�"�"�>�2��O�O�D�!��	
�
�
�r'c�|���sy�j|��j|��s���j�yyyrg)�remover�r�)r�r0r�r�s ���r&r�z$as_completed.<locals>._on_completionjs;��������A���������2��!�!�#�3�tr'c���K��j��d{���}|�tj�|j�S7�&�wrg)r#rr�rv)r�r0s �r&�
_wait_for_onez#as_completed.<locals>._wait_for_oners7������(�(�*����9��)�)�)��x�x�z��	
�s�A�>�'A)rr�rrJrLr�r��queuesr�r�get_event_loopr�r
r�r��ranger�)r�r�r�r%r�r�r��_r�r0r�r�s        @@@@r&r	r	Hs������$�����z�5�5�b�9��=�d�2�h�>O�>O�=P�Q�R�R���7�D�� � �"�D�14�R��9��A�M�!�$�'��9�D��N��$����	���N�+����#�����+�>��
�3�t�9�
���o����9:�s�A:D�C=�A.Dc#�K�d��y�w)z�Skip one event loop run cycle.

    This is a private helper for 'asyncio.sleep()', used
    when the 'delay' is set to 0.  It uses a bare 'yield'
    expression (which Task.__step knows how to handle)
    instead of creating a Future object.
    N�r�r'r&�__sleep0r��s����
�s�c��0K�|dkrt��d{���|Stj�}|j�}|j	|t
j||�}	|�d{���|j�S7�g7�#|j�wxYw�w)z9Coroutine that completes after a given time (in seconds).rN)r�rr!r�r�r�_set_result_unless_cancelledr�)�delayrvr%r��hs     r&r
r
�s������z��j����
��"�"�$�D�
�
�
�
!�F������<�<���	(�A���|�	���
�	����	���
�s:�B�A=�AB�#B�(A?�)B�,B�?B�B�Br$c��tj|�r&|�"|tj|�urtd��|Sd}t	j
|�s.t
j|�rd�}||�}d}ntd��|�tj�}	|j|�S#t$r|r|j��wxYw)zmWrap a coroutine or an awaitable in a future.

    If the argument is a Future, it is returned directly.
    zRThe future belongs to a different loop than the one specified as the loop argumentTc��"K�|�d{���S7��wrgr�)�	awaitables r&�_wrap_awaitablez&ensure_future.<locals>._wrap_awaitable�s����&��&��s��
�Fz:An asyncio.Future, a coroutine or an awaitable is required)rr�r/r�rrJr��isawaitablerLrr�rr,�close)�coro_or_futurer%�should_closer�s    r&r
r
�s���
����'����G�,=�,=�n�,M� M��E�F�
F����L��!�!�.�1����~�.�
'�-�^�<�N� �L��*�+�
+��|��$�$�&�������/�/������ � �"�
��s�B)�)Cc�*��eZdZdZ�fd�Zdd�Z�xZS)�_GatheringFuturez�Helper for gather().

    This overrides cancel() to cancel all the children and act more
    like Task.cancel(), which doesn't immediately mark itself as
    cancelled.
    c�B��t�|�|��||_d|_y)Nr$F)rGrH�	_children�_cancel_requested)r\�childrenr%r^s   �r&rHz_GatheringFuture.__init__�s"���
���d��#�!���!&��r'c��|j�ryd}|jD]}|j|��s�d}�|rd|_|S)NFr�T)r0rr�r)r\r��ret�childs    r&r�z_GatheringFuture.cancel�sH���9�9�;�����^�^�E��|�|��|�$���$��&*�D�"��
r'rg)r�r�r�r�rHr�r�r�s@r&rr�s����'�r'rF)�return_exceptionsc����	�
��|s7tj�}|j���jg��S��	�
��fd�}i}g�d�
d�	g}d}d�|D]�}||vrmt	||��}|�tj|�}||urd|_�
dz
�
|||<|j�r|j|�n|j|�n||}�j|���t�|���|D]
}||���S)a�Return a future aggregating results from the given coroutines/futures.

    Coroutines will be wrapped in a future and scheduled in the event
    loop. They will not necessarily be scheduled in the same order as
    passed in.

    All futures must share the same event loop.  If all the tasks are
    done successfully, the returned future's result is the list of
    results (in the order of the original sequence, not necessarily
    the order of results arrival).  If *return_exceptions* is True,
    exceptions in the tasks are treated the same as successful
    results, and gathered in the result list; otherwise, the first
    raised exception will be immediately propagated to the returned
    future.

    Cancellation: if the outer Future is cancelled, all children (that
    have not completed yet) are also cancelled.  If any child is
    cancelled, this is treated as if it raised CancelledError --
    the outer Future is *not* cancelled in this case.  (This is to
    prevent the cancellation of one child to cause other children to
    be cancelled.)

    If *return_exceptions* is False, cancelling gather() after it
    has been marked done won't cancel any submitted awaitables.
    For instance, gather can be marked done after propagating an
    exception to the caller, therefore, calling ``gather.cancel()``
    after catching an exception (raised by one of the awaitables) from
    gather won't cancel any other awaitables.
    c����dz
����j�r!|j�s|j�y�sV|j�r"|j�}�j	|�y|j�}|��j	|�y��k(r�g}�D]s}|j�r.tj|j�dn|j�}n"|j�}|�|j�}|j|��u�jr"|j�}�j	|�y�j|�yy)Nr�)r0r�ryr�rzrr�r�rv�appendrrw)	r�r��results�resr�	nfinished�nfuts�outerr	s	    �����r&�_done_callbackzgather.<locals>._done_callback�s,����Q��	��=�E�J�J�L��=�=�?��
�
��� ��}�}���/�/�1���#�#�C�(���m�m�o���?��'�'��,������G����=�=�?�%�3�3�!�1�1�9���+�+�-�C��-�-�/�C��{�!�j�j�l�����s�#� �"�&�&��/�/�1���#�#�C�(�� � ��)�;r'rNr$Fr)rr�r�rwr
rr/rKr0r
r�r)r	�coros_or_futuresr%r�
arg_to_fut�	done_futs�argr�rrrrs`       @@@@r&rr�s ���<��$�$�&���"�"�$��
�������5*�5*�n�J��H�
�E��I��I��D��E����j� ���$�/�C��|��(�(��-���#�~�
,1��(��Q�J�E�!�J�s�O��x�x�z�� � ��%��%�%�n�5��S�/�C������/ �2
�X�D�1�E����s����Lr'c������t|���j�r�Stj��}|j	���fd����fd�}�j���j|��S)a�Wait for a future, shielding it from cancellation.

    The statement

        task = asyncio.create_task(something())
        res = await shield(task)

    is exactly equivalent to the statement

        res = await something()

    *except* that if the coroutine containing it is cancelled, the
    task running in something() is not cancelled.  From the POV of
    something(), the cancellation did not happen.  But its caller is
    still cancelled, so the yield-from expression still raises
    CancelledError.  Note: If something() is cancelled by other means
    this will still cancel shield().

    If you want to completely ignore cancellation (not recommended)
    you can combine shield() with a try/except clause, as follows:

        task = asyncio.create_task(something())
        try:
            res = await shield(task)
        except CancelledError:
            res = None

    Save a reference to tasks passed to this function, to avoid
    a task disappearing mid-execution. The event loop only keeps
    weak references to tasks. A task that isn't referenced elsewhere
    may get garbage collected at any time, even before it's done.
    c�0���j�r!|j�s|j�y|j�r�j�y|j�}|��j|�y�j	|j��yrg)r�ryr�rzrwrv)�innerr�rs  �r&�_inner_done_callbackz$shield.<locals>._inner_done_callback�sj����?�?���?�?�$����!���?�?���L�L�N��/�/�#�C����#�#�C�(�� � �����0r'c�J���j�s�j��yyrg)r0r�)rrrs ��r&�_outer_done_callbackz$shield.<locals>._outer_done_callback�s ����z�z�|��&�&�';�<�r')r
r0rr/r�r�)rr%rrrrs   @@@r&rrask���B
�#��E��z�z�|������U�#�D���� �E�1�"=�
���0�1�	���0�1��Lr'c�����tj��std��tjj�����fd�}�j
|��S)zsSubmit a coroutine object to a given event loop.

    Return a concurrent.futures.Future to access the result.
    zA coroutine object is requiredc����	tjt������y#ttf$r�t
$r'}�j
�r�j|��d}~wwxYw)Nr$)r�
_chain_futurer
r�r�r��set_running_or_notify_cancelrz)r�r]r�r%s ���r&�callbackz*run_coroutine_threadsafe.<locals>.callback�s]���	��!�!�-��4�"@�&�I���-�.�	���	��2�2�4��$�$�S�)���	�s�!%�A$�"A�A$)rrJrL�
concurrentr�Future�call_soon_threadsafe)r]r%r"r�s`` @r&rr�sM���
�!�!�$�'��8�9�9�
�
�
�
&�
&�
(�F��	���h�'��Mr'c���ddd��fd�
}|S)a=Create a function suitable for use as a task factory on an event-loop.

        Example usage:

            loop.set_task_factory(
                asyncio.create_eager_task_factory(my_task_constructor))

        Now, tasks created will be started immediately (rather than being first
        scheduled to an event loop). The constructor argument can be any callable
        that returns a Task-compatible object and has a signature compatible
        with `Task.__init__`; it must have the `eager_start` keyword argument.

        Most applications will use `Task` for `custom_task_constructor` and in
        this case there's no need to call `create_eager_task_factory()`
        directly. Instead the  global `eager_task_factory` instance can be
        used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`.
        Nr�c����||||d��S)NTrAr�)r%r]r>rB�custom_task_constructors    �r&�factoryz*create_eager_task_factory.<locals>.factory�s���&��t�$��T�K�	Kr'r�)r(r)s` r&rr�s���&%)�$�K��Nr'c�.�tj|�y)z;Register an asyncio Task scheduled to run on an event loop.N)r+r��r=s r&rr�s������r'c�.�tj|�y)z6Register an asyncio Task about to be eagerly executed.N)r*r�r+s r&r�r��s�����T�r'c�h�tj|�}|�td|�d|�d���|t|<y)NzCannot enter into task z while another task z is being executed.�r"r#r,�r%r=rs   r&rr�sL��!�%�%�d�+�L����4�T�H�=#�#/�"2�2E�G�H�	H��N�4�r'c�h�tj|�}||urtd|�d|�d���t|=y)Nz
Leaving task z! does not match the current task �.r.r/s   r&rr�sJ��!�%�%�d�+�L��4���]�4�(�3/�/;�.>�a�A�B�	B��t�r'c�X�tj|�}|�	t|=|S|t|<|Srg)r"r#)r%r=r�s   r&r�r��s9���"�"�4�(�I��|��4� ��� $��t���r'c�.�tj|�y)z'Unregister a completed, scheduled Task.N)r+�discardr+s r&rrs�����T�"r'c�.�tj|�y)z6Unregister a task which finished its first eager step.N)r*r4r+s r&r�r�
s������r')rr�rr�rrr�r+r*r"rrg)Pr��__all__�concurrent.futuresr#rTr�r�r-�typesr:�weakrefrrrrrrrr�count�__next__rMrrr?�	_PyFuturer�_PyTask�_asyncio�_CTask�ImportErrorrrrrrr�rr�r�r	�	coroutiner�r
r
r$rrrrrr�WeakSetr+r�r*r"rr�rrr�rr��_py_current_task�_py_register_task�_py_register_eager_task�_py_unregister_task�_py_unregister_eager_task�_py_enter_task�_py_leave_task�_py_swap_current_task�_c_current_task�_c_register_task�_c_register_eager_task�_c_unregister_task�_c_unregister_eager_task�
_c_enter_task�
_c_leave_task�_c_swap_current_taskr�r'r&�<module>rSsM��6������������������
%�Y�_�_�Q�'�0�0��$�>�6
�z�7���z�z	��"��
�M�M�!�D�6�#�D�
�$�$�$�4�4���$�$�4�4���"�"�0�0�
�#�
�7�@ �
0�d)�X%�$!%�6�r���
��
��"+/��@�w�~�~��:16�C�L?�D�.�4/�t�4��#�7�?�?�$���u�����
�
 ���#�
�
 ��"��.��&��2������*��.�(�(�(�(�#�O�%��1��)��5���M��M�-���i�	��	��T�	��	�s$�F5�
G�5F>�=F>�G	�G