o
    éT•j  ã                   @   s8  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	ddl
mZ G dd„ dejƒZG dd„ dejƒZedkrše ¡ Ze e¡ d	eiZd
D ]	Zeƒ e ee< qOeeeƒZdadazd dlZW n	 eyq   Y nw eƒ Zde_e ¡  	 ze ¡  W dS  e y™   tr—t !¡ s—t "¡  daY q|w dS )é    Né   )Úfuturesc                       s$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )ÚAsyncIOInteractiveConsolec                    s*   t ƒ  |¡ | jj jtjO  _|| _d S )N)ÚsuperÚ__init__ÚcompileÚcompilerÚflagsÚastÚPyCF_ALLOW_TOP_LEVEL_AWAITÚloop)ÚselfÚlocalsr   ©Ú	__class__© ú'/usr/lib/python3.10/asyncio/__main__.pyr      s   
z"AsyncIOInteractiveConsole.__init__c                    sn   t j ¡ ‰‡ ‡‡fdd„}t |¡ zˆ ¡ W S  ty   ‚  ty6   tr/ˆ 	d¡ Y d S ˆ 
¡  Y d S w )Nc               
      sú   d a dat ˆ ˆj¡} z| ƒ }W n8 ty   ‚  ty1 } zdaˆ |¡ W Y d }~d S d }~w tyH } zˆ |¡ W Y d }~d S d }~ww t	 
|¡sUˆ |¡ d S zˆj |¡a t t ˆ¡ W d S  ty| } zˆ |¡ W Y d }~d S d }~ww )NFT)Úrepl_futureÚrepl_future_interruptedÚtypesÚFunctionTyper   Ú
SystemExitÚKeyboardInterruptÚset_exceptionÚBaseExceptionÚinspectÚiscoroutineÚ
set_resultr   Úcreate_taskr   Ú_chain_future)ÚfuncÚcoroÚexÚexc©ÚcodeÚfuturer   r   r   Úcallback   s6   

€
€þ

€ÿz3AsyncIOInteractiveConsole.runcode.<locals>.callbackz
KeyboardInterrupt
)Ú
concurrentr   ÚFuturer   Úcall_soon_threadsafeÚresultr   r   r   ÚwriteÚshowtraceback)r   r%   r'   r   r$   r   Úruncode   s   


üz!AsyncIOInteractiveConsole.runcode)Ú__name__Ú
__module__Ú__qualname__r   r.   Ú__classcell__r   r   r   r   r      s    r   c                   @   s   e Zd Zdd„ ZdS )Ú
REPLThreadc                 C   st   z*dt j› dt j› dtt ddƒ› d�}tj|dd� W tjd	d
td� t	 
t	j¡ d S tjd	d
td� t	 
t	j¡ w )Nzasyncio REPL z on zy
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
Úps1z>>> zimport asynciozexiting asyncio REPL...)ÚbannerÚexitmsgÚignorez ^coroutine .* was never awaited$)ÚmessageÚcategory)ÚsysÚversionÚplatformÚgetattrÚconsoleÚinteractÚwarningsÚfilterwarningsÚRuntimeWarningr   r*   Ústop)r   r5   r   r   r   ÚrunF   s*   
üÿþýûýzREPLThread.runN)r/   r0   r1   rD   r   r   r   r   r3   D   s    r3   Ú__main__Úasyncio>   Ú__file__r/   Ú__spec__Ú
__loader__Ú__package__Ú__builtins__FT)#r
   rF   r%   Úconcurrent.futuresr(   r   r:   Ú	threadingr   r@   Ú r   ÚInteractiveConsoler   ÚThreadr3   r/   Únew_event_loopr   Úset_event_loopÚrepl_localsÚkeyr   r>   r   r   ÚreadlineÚImportErrorÚrepl_threadÚdaemonÚstartÚrun_foreverr   ÚdoneÚcancelr   r   r   r   Ú<module>   sP    6

ÿ
úüå