Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
runners.cpython-314.pyc74 linesDownload Raw Back to __pycache__
1+
2��i?����Rt^RIt^RIt^RIt^RIt^RIt^RIt^RIHt^RIH	t	^RIH3t4^RIHt^RIHt!RR]P4t!R	R4tR5RRR/RltR
tR#)�RunnerN)�6coroutines)�events)�7exceptions)�tasks)�	constantsc�"�]tRt^tRtRtRtRtR#)�_State�created�initialized�closed�N)�__name__�8__module__�__qualname__�__firstlineno__�CREATED�INITIALIZED�CLOSED�__static_attributes__r
��Lib\asyncio\runners.pyr	r	s���G��K�
�Frr	c�ha�]tRt^toRtRRRR/RltRtRtRtR	t	R9R/Rlt10RtR
tRt
VtR#)ra�A context manager that controls event loop life cycle.11 12The context manager always creates a new event loop,13allows to run async functions inside it,14and properly finalizes the loop at the context manager exit.15 16If debug is True, the event loop will be run in debug mode.17If loop_factory is passed, it is used for new event loop creation.18 19asyncio.run(main(), debug=True)20 21is a shortcut for22 23with asyncio.Runner(debug=True) as runner:24    runner.run(main())25 26The run() method can be called multiple times within the runner's context.27 28This can be useful for interactive console (e.g. IPython),29unittest runners, console tools, -- everywhere when async code30is called from existing sync framework and where the preferred single31asyncio.run() call doesn't work.32 33�debugN�loop_factoryc��\PVnWnW nRVnRVn^VnRVnR#)NF)	r	r�_state�_debug�
_loop_factory�_loop�_context�_interrupt_count�_set_event_loop)�selfrrs&$$r�__init__�Runner.__init__1s6���n�n�����)����34���
� !���$��rc�&�VP4V#�N)�35_lazy_init�r#s&r�	__enter__�Runner.__enter__:s�������rc�&�VP4R#r')�close)r#�exc_type�exc_val�exc_tbs&&&&r�__exit__�Runner.__exit__>s���36�37�rc�j�VP\PJdR#VPp\	V4VPVP
44VPVP\P44VP'd\P!R4VP4RVn\PVnR# TP'd\P!R4XP4RTn\PTni;i)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-�Runner.closeAs����;�;�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�AD2c�:�VP4VP#)zReturn embedded event loop.)r(rr)s&r�get_loop�Runner.get_loopRs�������z�z�r�contextc�T�\P!4e\R4hVP4\P38!V4'g4\P!V4'd
RpV!V4pM\R4hVf
VPpVPPWR7p\P!4\P!4Jd�\P !\P"4\P$JdJ\&P(!VP*VR7p\P!\P"V4MRp^VnVPP1V4Ve^\P !\P"4VJd5\P!\P"\P$4### \,dRpL�i;i \2P4d;TP.^8�d(\7TRR4pTeT!4^8Xd\94hhi;i Te^\P !\P"4TJd5\P!\P"\P$4iii;i)z$Run code in the embedded event loop.Nz7Runner.run() cannot be called from a running event loopc��""�VGRjx�L39#L5ir'r
)�	awaitables&r�_wrap_awaitable�#Runner.run.<locals>._wrap_awaitablebs���!*�?�*�?�s��
�z:An asyncio.Future, a coroutine or an awaitable is required)r?)�	main_task�uncancel)r�_get_running_loop�RuntimeErrorr(r�iscoroutine�inspect�isawaitable�	TypeErrorr r�create_task�	threading�current_thread�main_thread�signal�	getsignal�SIGINT�default_int_handler�	functools�partial�40_on_sigint�41ValueErrorr!r5r�CancelledError�getattr�KeyboardInterrupt)r#�coror?rC�task�sigint_handlerrFs&&$    r�run�42Runner.runWs���#�#�%�1��I�K�
K�	
�����%�%�d�+�+��"�"�4�(�(�+�'�t�,���!8�9�9��?��m�m�G��z�z�%�%�d�%�<���$�$�&�)�*?�*?�*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,�3%G�#G2�
G/�.G/�2AI�I�A#J'c�J�VP\PJd\R4hVP\PJdR#VP43fU\P!4VnVP'g(\P!VP4RVn	MVP4VnVPe&VPPVP4\P!4Vn\PVnR#)zRunner is closedNT)rr	rrHrrr�new_event_looprr"r9r�	set_debug�contextvars�copy_contextr r)s&rr(�Runner._lazy_init�s����;�;�&�-�-�'��1�2�2��;�;�&�,�,�,�����%��.�.�0�D�J��'�'�'��%�%�d�j�j�1�'+��$���+�+�-�D�J��;�;�"��J�J� � ����-�#�0�0�2��
��(�(��rc���V;P^,
unVP^8XdEVP4'g/VP4VPP	R4R#\4h)�c��R#r'r
r
rr�<lambda>�#Runner._on_sigint.<locals>.<lambda>�s��DrN)r!�done�cancelr�call_soon_threadsafer[)r#�signum�framerEs&&&&rrW�Runner._on_sigint�sW������"��� � �A�%�i�n�n�.>�.>������J�J�+�+�L�9���!�!r)r rr!rrr"r)rrrr�__doc__r$r*r1r-r=r_r(rWr�__classdictcell__)�
__classdict__s@rrrsO�����6%��%�4�%���(�"�443I�4�3I�j)�&"�"rrrc���\P!4e\R4h\WR7;_uu_4pVP	V4uuRRR4# +'giR#;i)auExecute the coroutine and return the result.45 46This function runs the passed coroutine, taking care of47managing the asyncio event loop, finalizing asynchronous48generators and closing the default executor.49 50This function cannot be called when another asyncio event loop is51running in the same thread.52 53If debug is True, the event loop will be run in debug mode.54If loop_factory is passed, it is used for new event loop creation.55 56This function always creates a new event loop and closes it at the end.57It should be used as a main entry point for asyncio programs, and should58ideally only be called once.59 60The executor is given a timeout duration of 5 minutes to shutdown.61If the executor hasn't finished within that duration, a warning is62emitted and the executor is closed.63 64Example:65 66    async def main():67        await asyncio.sleep(1)68        print('hello')69 70    asyncio.run(main())71Nz8asyncio.run() cannot be called from a running event loop)rr)rrGrHrr_)�mainrr�runners&$$ rr_r_�sO��:���!�-��F�H�	H�72�e�	7�	7�6��z�z�$��738�	7�	7�	7�s�A�A$	c	�v�\P!V4pV'gR#VFpVP4K	VP\P!VRR/4VFTpVP4'dKVP
4fK/VPRRRVP
4RV/4KV	R#)N�return_exceptionsT�messagez1unhandled exception during asyncio.run() shutdown�	exceptionr])r�	all_tasksrmr5�gather�	cancelledr{�call_exception_handler)r:�	to_cancelr]s&  rr4r4�s�������%�I��������
��	���E�L�L�)�L�t�L�M����>�>�����>�>��'��'�'��N��T�^�^�-���)�
�	r)rr_)�__all__rd�enumrUrJrNrQ�rrrrr�Enumr	rr_r4r
rr�<module>r�sa��74�������
�������T�Y�Y��Q"�Q"�h# �t�# �$�# �Lr
codekingpro/portable-devtools · Team Ai