o
    f                     @   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re 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rt! st"  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


