o
    ˜»áf8  ã                   @   sB   d Z ddlmZ ddlmZ ddlmZ ddœdd„Zd	d
„ ZdS ))Úruné   )Ú
coroutines)Úevents)ÚtasksN)Údebugc                C   sü   t  ¡ dur
tdƒ‚t | ¡std | ¡ƒ‚t  ¡ }z;t  |¡ |dur)| 	|¡ | 
| ¡W zt|ƒ | 
| ¡ ¡ | 
| ¡ ¡ W t  d¡ | ¡  S t  d¡ | ¡  w zt|ƒ | 
| ¡ ¡ | 
| ¡ ¡ W t  d¡ | ¡  w t  d¡ | ¡  w )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})r   Ú_get_running_loopÚRuntimeErrorr   ÚiscoroutineÚ
ValueErrorÚformatÚnew_event_loopÚset_event_loopÚ	set_debugÚrun_until_completeÚ_cancel_all_tasksÚshutdown_asyncgensÚshutdown_default_executorÚclose)Úmainr   Úloop© r   ú&/usr/lib/python3.10/asyncio/runners.pyr      s8   ÿ






ÿ
ú


ÿ
r   c                 C   st   t  | ¡}|s	d S |D ]}| ¡  q|  t j|ddiŽ¡ |D ]}| ¡ r&q| ¡ d ur7|  d| ¡ |dœ¡ qd S )NÚreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)ÚmessageÚ	exceptionÚtask)r   Ú	all_tasksÚcancelr   ÚgatherÚ	cancelledr   Úcall_exception_handler)r   Ú	to_cancelr   r   r   r   r   7   s"   

ý€ür   )Ú__all__Ú r   r   r   r   r   r   r   r   r   Ú<module>   s    /