ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/asyncio/__pycache__/runners.cpython-311.opt-1.pyc

�

�f����dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZGd�d	ej��Z
Gd
�d��Zdd�d
�Zd�ZdS))�Runner�run�N�)�
coroutines)�events)�
exceptions)�tasksc��eZdZdZdZdZdS)�_State�created�initialized�closedN)�__name__�
__module__�__qualname__�CREATED�INITIALIZED�CLOSED���6/opt/alt/python311/lib64/python3.11/asyncio/runners.pyrrs�������G��K�
�F�F�Frrc�P�eZdZdZddd�d�Zd�Zd�Zd�Zd�Zdd	�d
�Z	d�Z
d�ZdS)
ra5A context manager that controls event loop life cycle.

    The context manager always creates a new event loop,
    allows to run async functions inside it,
    and properly finalizes the loop at the context manager exit.

    If debug is True, the event loop will be run in debug mode.
    If loop_factory is passed, it is used for new event loop creation.

    asyncio.run(main(), debug=True)

    is a shortcut for

    with asyncio.Runner(debug=True) as runner:
        runner.run(main())

    The run() method can be called multiple times within the runner's context.

    This can be useful for interactive console (e.g. IPython),
    unittest runners, console tools, -- everywhere when async code
    is called from existing sync framework and where the preferred single
    asyncio.run() call doesn't work.

    N)�debug�loop_factoryc�|�tj|_||_||_d|_d|_d|_d|_dS)NrF)	rr�_state�_debug�
_loop_factory�_loop�_context�_interrupt_count�_set_event_loop)�selfrrs   r�__init__zRunner.__init__1s>���n������)�����
���
� !���$����rc�.�|���|S�N)�
_lazy_init�r#s r�	__enter__zRunner.__enter__:s���������rc�.�|���dSr&)�close)r#�exc_type�exc_val�exc_tbs    r�__exit__zRunner.__exit__>s���
�
�����rc� �|jtjurdS	|j}t	|��|�|�����|�|�����|jrtj
d��|���d|_tj|_dS#|jrtj
d��|���d|_tj|_wxYw)zShutdown and close event loop.N)
rrrr�_cancel_all_tasks�run_until_complete�shutdown_asyncgens�shutdown_default_executorr"r�set_event_loopr+r)r#�loops  rr+zRunner.closeAs����;�f�0�0�0��F�
	(��:�D��d�#�#�#��#�#�D�$;�$;�$=�$=�>�>�>��#�#�D�$B�$B�$D�$D�E�E�E��#�
,��%�d�+�+�+��J�J�L�L�L��D�J� �-�D�K�K�K��	�#�
,��%�d�+�+�+��J�J�L�L�L��D�J� �-�D�K�'�'�'�'s
�A$C�A	D
c�8�|���|jS)zReturn embedded event loop.)r'rr(s r�get_loopzRunner.get_loopQs���������z�r��contextc��tj|��s"td�|�����t	j���t
d���|���|�|j}|j	�
||���}tj��tj
��urxtjtj��tjurNt%j|j|���}	tjtj|��n#t$rd}YnwxYwd}d|_	|j	�|��|�Jtjtj��|ur+tjtjtj��SSS#t.j$r<|jdkr/t3|dd��}|�|��dkrt5����wxYw#|�Jtjtj��|ur+tjtjtj��wwwxYw)z/Run a coroutine inside the embedded event loop.z"a coroutine was expected, got {!r}Nz7Runner.run() cannot be called from a running event loopr9)�	main_taskr�uncancel)r�iscoroutine�
ValueError�formatr�_get_running_loop�RuntimeErrorr'r r�create_task�	threading�current_thread�main_thread�signal�	getsignal�SIGINT�default_int_handler�	functools�partial�
_on_sigintr!r2r�CancelledError�getattr�KeyboardInterrupt)r#�coror:�task�sigint_handlerr=s      rrz
Runner.runVs5���%�d�+�+�	P��A�H�H��N�N�O�O�O��#�%�%�1��I�K�K�
K�	
�������?��m�G��z�%�%�d�G�%�<�<���$�&�&�)�*?�*A�*A�A�A�� ���/�/�6�3M�M�M�&�.�t��$�O�O�O�N�
&��
�f�m�^�<�<�<�<���
&�
&�
&�"&����	
&����"�N� !���	I��:�0�0��6�6��*��$�V�]�3�3�~�E�E��
�f�m�V�-G�H�H�H�H�+�E���(�	�	�	��$�q�(�(�"�4��T�:�:���'�H�H�J�J�!�O�O�+�-�-�-��	������*��$�V�]�3�3�~�E�E��
�f�m�V�-G�H�H�H�H�+�E���s,�>D�D-�,D-�:F!�!AG,�,G/�/AH>c���|jtjurtd���|jtjurdS|j�@t
j��|_|j	s t
j
|j��d|_	n|���|_|j�|j�|j��tj��|_tj|_dS)NzRunner is closedT)rrrrBrrr�new_event_looprr"r5r�	set_debug�contextvars�copy_contextr r(s rr'zRunner._lazy_init�s����;�&�-�'�'��1�2�2�2��;�&�,�,�,��F���%��.�0�0�D�J��'�
,��%�d�j�1�1�1�'+��$���+�+�-�-�D�J��;�"��J� � ���-�-�-�#�0�2�2��
��(����rc���|xjdz
c_|jdkrE|���s1|���|j�d���dSt���)Nrc��dSr&rrrr�<lambda>z#Runner._on_sigint.<locals>.<lambda>�s��D�r)r!�done�cancelr�call_soon_threadsaferP)r#�signum�framer<s    rrMzRunner._on_sigint�sn������"���� �A�%�%�i�n�n�.>�.>�%��������J�+�+�L�L�9�9�9��F��!�!�!r)rrr�__doc__r$r)r/r+r8rr'rMrrrrrs���������6!%�4�%�%�%�%�%�������(�(�(� ���
$(�+I�+I�+I�+I�+I�Z)�)�)�&"�"�"�"�"rr�rc���tj���td���t|���5}|�|��cddd��S#1swxYwYdS)a�Execute the coroutine and return the result.

    This function runs the passed coroutine, taking care of
    managing the asyncio event loop and finalizing asynchronous
    generators.

    This function cannot be called when another asyncio event loop is
    running in the same thread.

    If debug is True, the event loop will be run in debug mode.

    This function always creates a new event loop and closes it at the end.
    It should be used as a main entry point for asyncio programs, and should
    ideally only be called once.

    Example:

        async def main():
            await asyncio.sleep(1)
            print('hello')

        asyncio.run(main())
    Nz8asyncio.run() cannot be called from a running event looprb)rrArBrr)�mainr�runners   rrr�s���0��!�!�-��F�H�H�	H�
�e�	�	�	� ���z�z�$��� � � � � � � � � � � � ���� � � � � � s�A�A�Ac�b�tj|��}|sdS|D]}|����|�tj|ddi���|D]V}|���r�|����+|�d|���|d����WdS)N�return_exceptionsTz1unhandled exception during asyncio.run() shutdown)�message�	exceptionrR)r	�	all_tasksr]r2�gather�	cancelledri�call_exception_handler)r6�	to_cancelrRs   rr1r1�s������%�%�I������������
�
�
�
����E�L�)�L�t�L�L�M�M�M������>�>���	���>�>���'��'�'�N�!�^�^�-�-��)�)�
�
�
��	�r)�__all__rW�enumrKrDrG�sys�rrrr	�Enumrrrr1rrr�<module>rts&��
������������������
�
�
�
�
�
�
�
������������������������������T�Y����H"�H"�H"�H"�H"�H"�H"�H"�V� � � � � �B����r

Zerion Mini Shell 1.0