a XC?hM�@sBdZddlmZddlmZddlmZdd�dd�Zd d �ZdS) )�run�)� coroutines)�events)�tasksN)�debugcCsVt��durtd��t�|�s,td�|���t��}z�t�|�|durR|� |�|� |�Wz:t |�|� |� ��|� |� ��Wt�d�|��St�d�|��0Sz:t |�|� |� ��|� |� ��Wt�d�|��nt�d�|��0nRz:t |�|� |� ��|� |� ��Wt�d�|��nt�d�|��00dS)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 loopz"a coroutine was expected, got {!r})rZ_get_running_loop� RuntimeErrorrZ iscoroutine� ValueError�formatZnew_event_loopZset_event_loopZ set_debug�run_until_complete�_cancel_all_tasksZshutdown_asyncgensZshutdown_default_executor�close)�mainr�loop�r�4/opt/alt/python39/lib64/python3.9/asyncio/runners.pyrsJ �      �  �  �  �  � rcCsvt�|�}|sdS|D] }|��q|�tj||dd���|D]0}|��rNq@|��dur@|�d|��|d��q@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)�message� exception�task)rZ all_tasksZcancelr Z_gatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 7s"  � �r )�__all__�rrrrr rrrr�s    /