%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/asyncio/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/asyncio/__pycache__/runners.cpython-312.pyc

�

���f����dZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZGd	�d
ej�Z
Gd�d�Zddd
�d�Zd�Zy))�Runner�run�N�)�
coroutines)�events)�
exceptions)�tasks)�	constantsc��eZdZdZdZdZy)�_State�created�initialized�closedN)�__name__�
__module__�__qualname__�CREATED�INITIALIZED�CLOSED���&/usr/lib/python3.12/asyncio/runners.pyrrs���G��K�
�Frrc�N�eZdZdZddd�d�Zd�Zd�Zd�Zd�Zdd	�d
�Z	d�Z
d�Zy)
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|_y)NrF)	rr�_state�_debug�
_loop_factory�_loop�_context�_interrupt_count�_set_event_loop)�selfrrs   r�__init__zRunner.__init__0s:���n�n������)�����
���
� !���$��rc�&�|j�|S�N)�
_lazy_init�r%s r�	__enter__zRunner.__enter__9s�������rc�$�|j�yr()�close)r%�exc_type�exc_val�exc_tbs    r�__exit__zRunner.__exit__=s���
�
�rc�F�|jtjury	|j}t	|�|j|j
��|j|jtj��|jrtjd�|j�d|_tj|_y#|jrtjd�j�d|_tj|_wxYw)zShutdown and close event loop.N)rrrr!�_cancel_all_tasks�run_until_complete�shutdown_asyncgens�shutdown_default_executorr
�THREAD_JOIN_TIMEOUTr$r�set_event_loopr-r)r%�loops  rr-zRunner.close@s����;�;�f�0�0�0��	(��:�:�D��d�#��#�#�D�$;�$;�$=�>��#�#��.�.�y�/L�/L�M�
O��#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K��	�#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�s
�A$C�AD c�:�|j�|jS)zReturn embedded event loop.)r)r!r*s r�get_loopzRunner.get_loopQs�������z�z�r��contextc���tj|�stdj|���t	j
��t
d��|j�|�|j}|jj||��}tj�tj�urztjtj �tj"urGt%j&|j(|��}	tjtj |�nd}d|_	|jj-|�|�Ytjtj �|ur3tjtj tj"�SSS#t$rd}Y��wxYw#t.j0$r4|j*dkDr#t3|dd�}|�|�dk(r
t5���wxYw#|�Ytjtj �|ur3tjtj tj"�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 loopr<)�	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#r4r�CancelledError�getattr�KeyboardInterrupt)r%�coror=�task�sigint_handlerr@s      rrz
Runner.runVs����%�%�d�+��A�H�H��N�O�O��#�#�%�1��I�K�
K�	
�����?��m�m�G��z�z�%�%�d�G�%�<���$�$�&�)�*?�*?�*A�A�� � ����/�6�3M�3M�M�&�.�.�t���$�O�N�
&��
�
�f�m�m�^�<�"�N� !���	I��:�:�0�0��6��*��$�$�V�]�]�3�~�E��
�
�f�m�m�V�-G�-G�H�F�+��%�
&�"&��	
&���(�(�	��$�$�q�(�"�4��T�:���'�H�J�!�O�+�-�-��	���*��$�$�V�]�]�3�~�E��
�
�f�m�m�V�-G�-G�H�F�+�s,�$F,�6F=�,F:�9F:�=AH�H�AI$c�$�|jtjurtd��|jtjury|j
�Lt
j�|_|js<t
j|j�d|_	n|j�|_|j�%|jj|j�tj�|_tj|_y)NzRunner is closedT)rrrrErr r�new_event_loopr!r$r8r�	set_debug�contextvars�copy_contextr"r*s rr)zRunner._lazy_init�s����;�;�&�-�-�'��1�2�2��;�;�&�,�,�,�����%��.�.�0�D�J��'�'��%�%�d�j�j�1�'+��$��+�+�-�D�J��;�;�"��J�J� � ����-�#�0�0�2��
��(�(��rc���|xjdz
c_|jdk(r=|j�s-|j�|jj	d��yt��)Nrc��yr(rrrr�<lambda>z#Runner._on_sigint.<locals>.<lambda>�s�r)r#�done�cancelr!�call_soon_threadsaferS)r%�signum�framer?s    rrPzRunner._on_sigint�sT������"��� � �A�%�i�n�n�.>������J�J�+�+�L�9���!�!r)rrr�__doc__r&r+r1r-r;rr)rPrrrrrs=���6!%�4�%���(�"�
$(�+I�Z)�&"rrrc��tj��td��t||��5}|j	|�cddd�S#1swYyxYw)azExecute the coroutine and return the result.

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

    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.

    The executor is given a timeout duration of 5 minutes to shutdown.
    If the executor hasn't finished within that duration, a warning is
    emitted and the executor is closed.

    Example:

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

        asyncio.run(main())
    Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)�mainrr�runners    rrr�sT��8���!�-��F�H�	H�
�e�,�	7� �6��z�z�$�� � � �s�A�Ac�B�tj|�}|sy|D]}|j��|jtj|ddi��|D]G}|j�r�|j
���%|jd|j
�|d���Iy)N�return_exceptionsTz1unhandled exception during asyncio.run() shutdown)�message�	exceptionrU)r	�	all_tasksr`r4�gather�	cancelledrk�call_exception_handler)r9�	to_cancelrUs   rr3r3�s�������%�I���������
��	���E�L�L�)�L�t�L�M�����>�>����>�>��'��'�'�N�!�^�^�-��)�
�	r)�__all__rZ�enumrNrGrJ�rrrr	r
�Enumrrrr3rrr�<module>rusW��
������
�������T�Y�Y��I"�I"�X�$�" �Jr

Zerion Mini Shell 1.0