o
    DXh3                     @   sB  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d	 e Zee d
eiZdD ]	Ze e ee< qTeeeZdadazd dlZW n	 eyv   Y nw e Zde_e  	 ze   W dS  e!y   trt" st#  daY qw 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__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr
   	__class__ :/opt/python-3.10.19/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inspectZiscoroutine
set_resultr
   Zcreate_taskr   Z_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   writeZ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.
Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsgignorez ^coroutine .* was never awaited$)messagecategory)sysversionplatformgetattrconsoleZinteractwarningsfilterwarningsRuntimeWarningr
   r%   stop)r   r.   r   r   r   runF   s*   
zREPLThread.runN)r)   r*   r+   r;   r   r   r   r   r-   D   s    r-   __main__zcpython.run_stdinasyncio>   __file____spec____builtins____package__r)   
__loader__FT)$r	   r=   r    concurrent.futuresr#   r   r2   	threadingr   r7    r   ZInteractiveConsoler   Threadr-   r)   auditZnew_event_loopr
   Zset_event_loopZrepl_localskeyr   r6   r   r   readlineImportErrorZrepl_threaddaemonstartZrun_foreverr   donecancelr   r   r   r   <module>   sR    6



