a
    ´i3  ã                   @   sT  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�rPe d	¡ e ¡ Ze e¡ d
eiZdD ]Zeƒ e ee< qªeeeƒZdadazd dlZW n eyî   Y n0 eƒ Zde_e ¡  ze  ¡  W n6 e!�yF   t�r<t "¡ �s<t #¡  daY �qY n0 �qP�q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__© ú(/usr/lib64/python3.9/asyncio/__main__.pyr      s    z"AsyncIOInteractiveConsole.__init__c                    sp   t j ¡ ‰‡ ‡‡fdd„}t |¡ z
ˆ ¡ W S  tyB   ‚ Y n* tyj   tr^ˆ 	d¡ nˆ 
¡  Y n0 d S )Nc               
      s   d a dat ˆ ˆj¡} z
| ƒ }W nt ty4   ‚ Y nb tyf } zdaˆ |¡ W Y d }~d S d }~0  ty” } zˆ |¡ W Y d }~d S d }~0 0 t	 
|¡s®ˆ |¡ d S zˆj |¡a t t ˆ¡ W n0 t� yú } zˆ |¡ W Y d }~n
d }~0 0 d S )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   s,    




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   sv   zRd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¡ ntjd	d
td� t	 
t	j¡ 0 d S )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>   r)   Ú__builtins__Ú__package__Ú
__loader__Ú__spec__Ú__file__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>   sH   6



