a
    åze*Ê  ã                   @   sæ  d 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	Z	ddl
Z
ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ dZe
jdkrþedƒ‚dd„ ZG dd„ dejƒZG dd„ dej ƒZ!G dd„ dej"ej#ƒZ$G dd„ dej%ƒZ&G dd„ dƒZ'G dd„ de'ƒZ(d d!„ Z)G d"d#„ d#e'ƒZ*G d$d%„ d%e*ƒZ+G d&d'„ d'e*ƒZ,G d(d)„ d)e'ƒZ-G d*d+„ d+e'ƒZ.G d,d-„ d-ej/ƒZ0eZ1e0Z2dS ).z2Selector event loop for Unix with signal handling.é    Né   )Úbase_events)Úbase_subprocess)Ú	constants)Ú
coroutines)Úevents)Ú
exceptions)Úfutures)Úselector_events)Útasks)Ú
transports)Úlogger)ÚSelectorEventLoopÚAbstractChildWatcherÚSafeChildWatcherÚFastChildWatcherÚPidfdChildWatcherÚMultiLoopChildWatcherÚThreadedChildWatcherÚDefaultEventLoopPolicyÚwin32z+Signals are not really supported on Windowsc                 C   s   dS )zDummy signal handler.N© )ÚsignumÚframer   r   ú)/usr/lib/python3.9/asyncio/unix_events.pyÚ_sighandler_noop*   s    r   c                       sÊ   e Zd ZdZd)‡ fdd„	Z‡ fdd„Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
d*dd„Zd+dd„Zd,dd„Zdd„ Zd-dddddœdd„Zd.ddddddœdd „Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Z‡  ZS )/Ú_UnixSelectorEventLoopzdUnix event loop.

    Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
    Nc                    s   t ƒ  |¡ i | _d S ©N)ÚsuperÚ__init__Ú_signal_handlers)ÚselfÚselector©Ú	__class__r   r   r   5   s    z_UnixSelectorEventLoop.__init__c                    sZ   t ƒ  ¡  t ¡ s.t| jƒD ]}|  |¡ qn(| jrVtjd| ›dt	| d | j 
¡  d S )NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal©Úsource)r   ÚcloseÚsysÚis_finalizingÚlistr    Úremove_signal_handlerÚwarningsÚwarnÚResourceWarningÚclear©r!   Úsigr#   r   r   r'   9   s    
üz_UnixSelectorEventLoop.closec                 C   s   |D ]}|sq|   |¡ qd S r   )Ú_handle_signal)r!   Údatar   r   r   r   Ú_process_self_dataG   s    z)_UnixSelectorEventLoop._process_self_datac                 G   sR  t  |¡st  |¡rtdƒ‚|  |¡ |  ¡  zt | j 	¡ ¡ W n4 t
tfyv } ztt|ƒƒ‚W Y d}~n
d}~0 0 t ||| d¡}|| j|< zt |t¡ t |d¡ W nž tyL } z„| j|= | jszt d¡ W n6 t
tfy } zt d|¡ W Y d}~n
d}~0 0 |jtjkr6td|› dƒ‚n‚ W Y d}~n
d}~0 0 dS )zÃAdd a handler for a signal.  UNIX only.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        z3coroutines cannot be used with add_signal_handler()NFéÿÿÿÿúset_wakeup_fd(-1) failed: %súsig ú cannot be caught)r   ZiscoroutineZiscoroutinefunctionÚ	TypeErrorÚ_check_signalÚ_check_closedÚsignalÚset_wakeup_fdZ_csockÚfilenoÚ
ValueErrorÚOSErrorÚRuntimeErrorÚstrr   ÚHandler    r   Úsiginterruptr   ÚinfoÚerrnoÚEINVAL)r!   r1   ÚcallbackÚargsÚexcÚhandleZnexcr   r   r   Úadd_signal_handlerN   s2    
ÿ
"
"z)_UnixSelectorEventLoop.add_signal_handlerc                 C   s8   | j  |¡}|du rdS |jr*|  |¡ n
|  |¡ dS )z2Internal helper that is the actual signal handler.N)r    ÚgetZ
_cancelledr+   Z_add_callback_signalsafe)r!   r1   rK   r   r   r   r2   {   s    z%_UnixSelectorEventLoop._handle_signalc              
   C   sè   |   |¡ z| j|= W n ty*   Y dS 0 |tjkr>tj}ntj}zt ||¡ W nD ty˜ } z,|jtj	kr‚t
d|› dƒ‚n‚ W Y d}~n
d}~0 0 | jsäzt d¡ W n4 ttfyâ } zt d|¡ W Y d}~n
d}~0 0 dS )zwRemove a handler for a signal.  UNIX only.

        Return True if a signal handler was removed, False if not.
        Fr7   r8   Nr5   r6   T)r:   r    ÚKeyErrorr<   ÚSIGINTÚdefault_int_handlerÚSIG_DFLr@   rF   rG   rA   r=   r?   r   rE   )r!   r1   ÚhandlerrJ   r   r   r   r+   …   s(    

"z,_UnixSelectorEventLoop.remove_signal_handlerc                 C   s6   t |tƒstd|›ƒ‚|t ¡ vr2td|› ƒ‚dS )zÁInternal helper to validate a signal.

        Raise ValueError if the signal number is invalid or uncatchable.
        Raise RuntimeError if there is a problem setting up the handler.
        zsig must be an int, not zinvalid signal number N)Ú
isinstanceÚintr9   r<   Úvalid_signalsr?   r0   r   r   r   r:   ¥   s    
z$_UnixSelectorEventLoop._check_signalc                 C   s   t | ||||ƒS r   )Ú_UnixReadPipeTransport©r!   ÚpipeÚprotocolÚwaiterÚextrar   r   r   Ú_make_read_pipe_transport±   s    z0_UnixSelectorEventLoop._make_read_pipe_transportc                 C   s   t | ||||ƒS r   )Ú_UnixWritePipeTransportrW   r   r   r   Ú_make_write_pipe_transportµ   s    z1_UnixSelectorEventLoop._make_write_pipe_transportc	              
   Ë   sÌ   t  ¡ °}
|
 ¡ stdƒ‚|  ¡ }t| |||||||f||dœ|	¤Ž}|
 | ¡ | j|¡ z|I d H  W n@ t	t
fy€   ‚ Y n* ty¨   | ¡  | ¡ I d H  ‚ Y n0 W d   ƒ n1 s¾0    Y  |S )NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rZ   r[   )r   Úget_child_watcherÚ	is_activerA   Úcreate_futureÚ_UnixSubprocessTransportÚadd_child_handlerZget_pidÚ_child_watcher_callbackÚ
SystemExitÚKeyboardInterruptÚBaseExceptionr'   Ú_wait)r!   rY   rI   ÚshellÚstdinÚstdoutÚstderrÚbufsizer[   ÚkwargsÚwatcherrZ   Útranspr   r   r   Ú_make_subprocess_transport¹   s.    

ÿþý
ÿ&z1_UnixSelectorEventLoop._make_subprocess_transportc                 C   s   |   |j|¡ d S r   )Úcall_soon_threadsafeZ_process_exited)r!   ÚpidÚ
returncoderp   r   r   r   rd   ×   s    z._UnixSelectorEventLoop._child_watcher_callback)ÚsslÚsockÚserver_hostnameÚssl_handshake_timeoutc          	      Ã   s
  |r|d u r6t dƒ‚n |d ur&t dƒ‚|d ur6t dƒ‚|d ur¤|d urNt dƒ‚t |¡}t tjtjd¡}z | d¡ |  ||¡I d H  W qä   | ¡  ‚ Y qä0 n@|d u r´t dƒ‚|j	tjksÌ|j
tjkrÚt d|›ƒ‚| d¡ | j|||||d	I d H \}}||fS )
Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslú1ssl_handshake_timeout is only meaningful with sslú3path and sock can not be specified at the same timer   Fzno path and sock were specifiedú.A UNIX Domain Stream Socket was expected, got )rx   )r?   ÚosÚfspathÚsocketÚAF_UNIXÚSOCK_STREAMÚsetblockingZsock_connectr'   ÚfamilyÚtypeZ_create_connection_transport)	r!   Úprotocol_factoryÚpathru   rv   rw   rx   Ú	transportrY   r   r   r   Úcreate_unix_connectionÚ   sL    ÿÿÿ



ÿÿ
þz-_UnixSelectorEventLoop.create_unix_connectionéd   T)rv   Úbacklogru   rx   Ústart_servingc             
   Ã   sÈ  t |tƒrtdƒ‚|d ur&|s&tdƒ‚|d urJ|d ur@tdƒ‚t |¡}t tjtj¡}|d dvrÊz t	 
t 	|¡j¡r„t |¡ W nB ty˜   Y n2 tyÈ } zt d||¡ W Y d }~n
d }~0 0 z| |¡ W nn ty2 }	 z@| ¡  |	jtjkrd|›d}
ttj|
ƒd ‚n‚ W Y d }	~	nd }	~	0    | ¡  ‚ Y n0 n<|d u r\td	ƒ‚|jtjksx|jtjkr†td
|›ƒ‚| d¡ t | |g||||¡}|rÄ| ¡  t d¡I d H  |S )Nz*ssl argument must be an SSLContext or Nonery   rz   r   )r   ú z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedr{   F)rS   Úboolr9   r?   r|   r}   r~   r   r€   ÚstatÚS_ISSOCKÚst_modeÚremoveÚFileNotFoundErrorr@   r   ÚerrorÚbindr'   rF   Z
EADDRINUSEr‚   rƒ   r   r   ZServerZ_start_servingr   Úsleep)r!   r„   r…   rv   r‰   ru   rx   rŠ   ÚerrrJ   ÚmsgZserverr   r   r   Úcreate_unix_server  sh    
ÿ
ÿ
ÿ

ÿ
ÿÿ
ÿz)_UnixSelectorEventLoop.create_unix_serverc           
   
   Ã   sÖ   z
t j W n ty&   t d¡‚Y n0 z| ¡ }W n4 ttjfyh } zt d¡‚W Y d }~n
d }~0 0 zt  |¡j	}W n t
y–   t d¡‚Y n0 |r |n|}|s¬dS |  ¡ }	|  |	d |||||d¡ |	I d H S )Nzos.sendfile() is not availableznot a regular filer   )r|   ÚsendfileÚAttributeErrorr   ÚSendfileNotAvailableErrorr>   ÚioÚUnsupportedOperationÚfstatÚst_sizer@   ra   Ú_sock_sendfile_native_impl)
r!   rv   ÚfileÚoffsetÚcountr>   r•   ÚfsizeÚ	blocksizeÚfutr   r   r   Ú_sock_sendfile_nativeJ  s,    
ÿ
 ÿz,_UnixSelectorEventLoop._sock_sendfile_nativec	                 C   s,  |  ¡ }	|d ur|  |¡ | ¡ r4|  |||¡ d S |rd|| }|dkrd|  |||¡ | |¡ d S zt |	|||¡}
W nD ttfyÄ   |d u r |  	||¡ |  
|	| j||	||||||¡
 Y nd tyj } zŽ|d ur|jtjkrt|ƒturtdtjƒ}||_|}|dkr>t d¡}|  |||¡ | |¡ n|  |||¡ | |¡ W Y d }~nÆd }~0  ttfy‚   ‚ Y n¦ ty¾ } z$|  |||¡ | |¡ W Y d }~nrd }~0 0 |
dkrä|  |||¡ | |¡ nD||
7 }||
7 }|d u r
|  	||¡ |  
|	| j||	||||||¡
 d S )Nr   zsocket is not connectedzos.sendfile call failed)r>   Úremove_writerÚ	cancelledÚ_sock_sendfile_update_fileposÚ
set_resultr|   r˜   ÚBlockingIOErrorÚInterruptedErrorÚ_sock_add_cancellation_callbackZ
add_writerrŸ   r@   rF   ZENOTCONNrƒ   ÚConnectionErrorÚ	__cause__r   rš   Úset_exceptionre   rf   rg   )r!   r¥   Zregistered_fdrv   r>   r¡   r¢   r¤   Ú
total_sentÚfdÚsentrJ   Únew_excr•   r   r   r   rŸ   a  sp    

þ


ÿ
þÿ
ÿ 

þz1_UnixSelectorEventLoop._sock_sendfile_native_implc                 C   s   |dkrt  ||t j¡ d S ©Nr   )r|   ÚlseekÚSEEK_SET)r!   r>   r¡   r±   r   r   r   r©   §  s    z4_UnixSelectorEventLoop._sock_sendfile_update_fileposc                    s   ‡ ‡fdd„}|  |¡ d S )Nc                    s&   |   ¡ r"ˆ ¡ }|dkr"ˆ  |¡ d S )Nr5   )r¨   r>   r§   )r¥   r²   ©r!   rv   r   r   Úcb¬  s    zB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb)Úadd_done_callback)r!   r¥   rv   r¹   r   r¸   r   r­   «  s    z6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   r4   rL   r2   r+   r:   r\   r^   rq   rd   r‡   r—   r¦   rŸ   r©   r­   Ú__classcell__r   r   r#   r   r   /   sB   -
   ÿ
  ÿ
 þ
 ÿü. ÿüCFr   c                       sŠ   e Zd ZdZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zejfdd„Zddd„Zdd„ Zdd„ Z‡  ZS ) rV   i   Nc                    sÚ   t ƒ  |¡ || jd< || _|| _| ¡ | _|| _d| _d| _	t
 | j¡j}t |¡s„t |¡s„t |¡s„d | _d | _d | _tdƒ‚t
 | jd¡ | j | jj| ¡ | j | jj| j| j¡ |d urÖ| j tj|d ¡ d S )NrX   Fz)Pipe transport is for pipes/sockets only.)r   r   Ú_extraÚ_loopÚ_piper>   Ú_filenoÚ	_protocolÚ_closingÚ_pausedr|   r   r   r   ÚS_ISFIFOrŽ   ÚS_ISCHRr?   Úset_blockingÚ	call_soonÚconnection_madeÚ_add_readerÚ_read_readyr	   Ú_set_result_unless_cancelled)r!   ÚlooprX   rY   rZ   r[   Úmoder#   r   r   r   ¸  s6    


ÿþÿ
ÿz_UnixReadPipeTransport.__init__c                 C   sÀ   | j jg}| jd u r | d¡ n| jr0| d¡ | d| j› ¡ t| jdd ƒ}| jd ur|d urt 	|| jt
j¡}|r„| d¡ q°| d¡ n | jd ur¦| d¡ n
| d¡ d d	 |¡¡S )
NÚclosedÚclosingúfd=Ú	_selectorÚpollingÚidleÚopenú<{}>ú )r$   r»   rÂ   ÚappendrÅ   rÃ   ÚgetattrrÁ   r
   Ú_test_selector_eventÚ	selectorsÚ
EVENT_READÚformatÚjoin)r!   rE   r"   rÕ   r   r   r   Ú__repr__Ö  s$    



ÿ

z_UnixReadPipeTransport.__repr__c              
   C   sº   zt  | j| j¡}W nD ttfy*   Y nŒ tyX } z|  |d¡ W Y d }~nfd }~0 0 |rl| j 	|¡ nJ| j
 ¡ r‚t d| ¡ d| _| j
 | j¡ | j
 | jj¡ | j
 | jd ¡ d S )Nz"Fatal read error on pipe transportú%r was closed by peerT)r|   ÚreadrÃ   Úmax_sizer«   r¬   r@   Ú_fatal_errorrÄ   Zdata_receivedrÁ   Ú	get_debugr   rE   rÅ   Ú_remove_readerrÊ   Zeof_receivedÚ_call_connection_lost)r!   r3   rJ   r   r   r   rÍ   ë  s    "
z"_UnixReadPipeTransport._read_readyc                 C   s>   | j s| jrd S d| _| j | j¡ | j ¡ r:t d| ¡ d S )NTz%r pauses reading)rÅ   rÆ   rÁ   rç   rÃ   ræ   r   Údebug©r!   r   r   r   Úpause_readingý  s    
z$_UnixReadPipeTransport.pause_readingc                 C   sB   | j s| jsd S d| _| j | j| j¡ | j ¡ r>t d| ¡ d S )NFz%r resumes reading)	rÅ   rÆ   rÁ   rÌ   rÃ   rÍ   ræ   r   ré   rê   r   r   r   Úresume_reading  s    
z%_UnixReadPipeTransport.resume_readingc                 C   s
   || _ d S r   ©rÄ   ©r!   rY   r   r   r   Úset_protocol  s    z#_UnixReadPipeTransport.set_protocolc                 C   s   | j S r   rí   rê   r   r   r   Úget_protocol  s    z#_UnixReadPipeTransport.get_protocolc                 C   s   | j S r   ©rÅ   rê   r   r   r   Ú
is_closing  s    z!_UnixReadPipeTransport.is_closingc                 C   s   | j s|  d ¡ d S r   )rÅ   Ú_closerê   r   r   r   r'     s    z_UnixReadPipeTransport.closec                 C   s,   | j d ur(|d| ›t| d | j  ¡  d S ©Nzunclosed transport r%   ©rÂ   r.   r'   ©r!   Ú_warnr   r   r   Ú__del__  s    
z_UnixReadPipeTransport.__del__úFatal error on pipe transportc                 C   sZ   t |tƒr4|jtjkr4| j ¡ rLtjd| |dd n| j ||| | j	dœ¡ |  
|¡ d S ©Nz%r: %sT©Úexc_info)ÚmessageÚ	exceptionr†   rY   )rS   r@   rF   ZEIOrÁ   ræ   r   ré   Úcall_exception_handlerrÄ   ró   ©r!   rJ   rý   r   r   r   rå     s    
üz#_UnixReadPipeTransport._fatal_errorc                 C   s(   d| _ | j | j¡ | j | j|¡ d S ©NT)rÅ   rÁ   rç   rÃ   rÊ   rè   ©r!   rJ   r   r   r   ró   -  s    z_UnixReadPipeTransport._closec                 C   sP   z,| j  |¡ W | j ¡  d | _d | _ d | _n| j ¡  d | _d | _ d | _0 d S r   ©rÄ   Zconnection_lostrÂ   r'   rÁ   r  r   r   r   rè   2  s    
ý
z,_UnixReadPipeTransport._call_connection_lost)NN)rù   )r»   r¼   r½   rä   r   rá   rÍ   rë   rì   rï   rð   rò   r'   r,   r-   rø   rå   ró   rè   r¿   r   r   r#   r   rV   ´  s   
rV   c                       s¨   e Zd Zd%‡ fdd„	Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zejfdd„Zdd„ Zd&dd „Zd'd!d"„Zd#d$„ Z‡  ZS )(r]   Nc           
         sþ   t ƒ  ||¡ || jd< || _| ¡ | _|| _tƒ | _d| _	d| _
t | j¡j}t |¡}t |¡}t |¡}	|s”|s”|	s”d | _d | _d | _tdƒ‚t | jd¡ | j | jj| ¡ |	sÈ|ràtj d¡sà| j | jj| j| j¡ |d urú| j tj|d ¡ d S )NrX   r   Fz?Pipe transport is only for pipes, sockets and character devicesZaix)r   r   rÀ   rÂ   r>   rÃ   rÄ   Ú	bytearrayÚ_bufferÚ
_conn_lostrÅ   r|   r   r   r   rÈ   rÇ   rŽ   r?   rÉ   rÁ   rÊ   rË   r(   ÚplatformÚ
startswithrÌ   rÍ   r	   rÎ   )
r!   rÏ   rX   rY   rZ   r[   rÐ   Zis_charÚis_fifoÚ	is_socketr#   r   r   r   ?  s6    




ÿ
ÿz _UnixWritePipeTransport.__init__c                 C   sØ   | j jg}| jd u r | d¡ n| jr0| d¡ | d| j› ¡ t| jdd ƒ}| jd ur¨|d ur¨t 	|| jt
j¡}|r„| d¡ n
| d¡ |  ¡ }| d|› ¡ n | jd ur¾| d¡ n
| d¡ d	 d
 |¡¡S )NrÑ   rÒ   rÓ   rÔ   rÕ   rÖ   zbufsize=r×   rØ   rÙ   )r$   r»   rÂ   rÚ   rÅ   rÃ   rÛ   rÁ   r
   rÜ   rÝ   ÚEVENT_WRITEÚget_write_buffer_sizerß   rà   )r!   rE   r"   rÕ   rm   r   r   r   rá   d  s(    



ÿ


z _UnixWritePipeTransport.__repr__c                 C   s
   t | jƒS r   )Úlenr  rê   r   r   r   r  |  s    z-_UnixWritePipeTransport.get_write_buffer_sizec                 C   s6   | j  ¡ rt d| ¡ | jr*|  tƒ ¡ n|  ¡  d S )Nrâ   )rÁ   ræ   r   rE   r  ró   ÚBrokenPipeErrorrê   r   r   r   rÍ     s
    
z#_UnixWritePipeTransport._read_readyc              
   C   s.  t |tƒrt|ƒ}|sd S | js&| jrN| jtjkr<t d¡ |  jd7  _d S | j	szt
 | j|¡}W nn ttfy‚   d}Y nV ttfy˜   ‚ Y n@ tyÖ } z(|  jd7  _|  |d¡ W Y d }~d S d }~0 0 |t|ƒkrèd S |dkrt|ƒ|d … }| j | j| j¡ |  j	|7  _	|  ¡  d S )Nz=pipe closed by peer or os.write(pipe, data) raised exception.r   r   ú#Fatal write error on pipe transport)rS   r  Ú
memoryviewr  rÅ   r   Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESr   Úwarningr  r|   ÚwriterÃ   r«   r¬   re   rf   rg   rå   r  rÁ   Z_add_writerÚ_write_readyZ_maybe_pause_protocol)r!   r3   ÚnrJ   r   r   r   r  ˆ  s6    


z_UnixWritePipeTransport.writec              
   C   sþ   zt  | j| j¡}W n€ ttfy*   Y nÐ ttfy@   ‚ Y nº ty” } z>| j 	¡  |  j
d7  _
| j | j¡ |  |d¡ W Y d }~nnd }~0 0 |t| jƒkræ| j 	¡  | j | j¡ |  ¡  | jrâ| j | j¡ |  d ¡ d S |dkrú| jd |…= d S )Nr   r  r   )r|   r  rÃ   r  r«   r¬   re   rf   rg   r/   r  rÁ   Ú_remove_writerrå   r  Z_maybe_resume_protocolrÅ   rç   rè   )r!   r  rJ   r   r   r   r  «  s*    
"

z$_UnixWritePipeTransport._write_readyc                 C   s   dS r  r   rê   r   r   r   Úcan_write_eofÇ  s    z%_UnixWritePipeTransport.can_write_eofc                 C   s8   | j r
d S d| _ | js4| j | j¡ | j | jd ¡ d S r  )rÅ   r  rÁ   rç   rÃ   rÊ   rè   rê   r   r   r   Ú	write_eofÊ  s    z!_UnixWritePipeTransport.write_eofc                 C   s
   || _ d S r   rí   rî   r   r   r   rï   Ó  s    z$_UnixWritePipeTransport.set_protocolc                 C   s   | j S r   rí   rê   r   r   r   rð   Ö  s    z$_UnixWritePipeTransport.get_protocolc                 C   s   | j S r   rñ   rê   r   r   r   rò   Ù  s    z"_UnixWritePipeTransport.is_closingc                 C   s   | j d ur| js|  ¡  d S r   )rÂ   rÅ   r  rê   r   r   r   r'   Ü  s    z_UnixWritePipeTransport.closec                 C   s,   | j d ur(|d| ›t| d | j  ¡  d S rô   rõ   rö   r   r   r   rø   á  s    
z_UnixWritePipeTransport.__del__c                 C   s   |   d ¡ d S r   )ró   rê   r   r   r   Úabortæ  s    z_UnixWritePipeTransport.abortrù   c                 C   sN   t |tƒr(| j ¡ r@tjd| |dd n| j ||| | jdœ¡ |  |¡ d S rú   )	rS   r@   rÁ   ræ   r   ré   rÿ   rÄ   ró   r   r   r   r   rå   é  s    

üz$_UnixWritePipeTransport._fatal_errorc                 C   sF   d| _ | jr| j | j¡ | j ¡  | j | j¡ | j | j|¡ d S r  )	rÅ   r  rÁ   r  rÃ   r/   rç   rÊ   rè   r  r   r   r   ró   ÷  s    
z_UnixWritePipeTransport._closec                 C   sP   z,| j  |¡ W | j ¡  d | _d | _ d | _n| j ¡  d | _d | _ d | _0 d S r   r  r  r   r   r   rè   ÿ  s    
ý
z-_UnixWritePipeTransport._call_connection_lost)NN)rù   )N)r»   r¼   r½   r   rá   r  rÍ   r  r  r  r  rï   rð   rò   r'   r,   r-   rø   r  rå   ró   rè   r¿   r   r   r#   r   r]   <  s"   %	#	

r]   c                   @   s   e Zd Zdd„ ZdS )rb   c           	   	   K   s¢   d }|t jkrt ¡ \}}zht j|f||||d|dœ|¤Ž| _|d urh| ¡  t| ¡ d|d| j_	d }W |d urž| ¡  | ¡  n|d urœ| ¡  | ¡  0 d S )NF)ri   rj   rk   rl   Úuniversal_newlinesrm   Úwb)Ú	buffering)
Ú
subprocessÚPIPEr~   Ú
socketpairÚPopenÚ_procr'   r×   Údetachrj   )	r!   rI   ri   rj   rk   rl   rm   rn   Zstdin_wr   r   r   Ú_start  s,    
ÿþþ
þz_UnixSubprocessTransport._startN)r»   r¼   r½   r"  r   r   r   r   rb   	  s   rb   c                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )r   aH  Abstract base class for monitoring child processes.

    Objects derived from this class monitor a collection of subprocesses and
    report their termination or interruption by a signal.

    New callbacks are registered with .add_child_handler(). Starting a new
    process must be done within a 'with' block to allow the watcher to suspend
    its activity until the new process if fully registered (this is needed to
    prevent a race condition in some implementations).

    Example:
        with watcher:
            proc = subprocess.Popen("sleep 1")
            watcher.add_child_handler(proc.pid, callback)

    Notes:
        Implementations of this class must be thread-safe.

        Since child watcher objects may catch the SIGCHLD signal and call
        waitpid(-1), there should be only one active object per process.
    c                 G   s
   t ƒ ‚dS )a  Register a new child handler.

        Arrange for callback(pid, returncode, *args) to be called when
        process 'pid' terminates. Specifying another callback for the same
        process replaces the previous handler.

        Note: callback() must be thread-safe.
        N©ÚNotImplementedError©r!   rs   rH   rI   r   r   r   rc   9  s    	z&AbstractChildWatcher.add_child_handlerc                 C   s
   t ƒ ‚dS )z Removes the handler for process 'pid'.

        The function returns True if the handler was successfully removed,
        False if there was nothing to remove.Nr#  ©r!   rs   r   r   r   Úremove_child_handlerD  s    z)AbstractChildWatcher.remove_child_handlerc                 C   s
   t ƒ ‚dS )zÔAttach the watcher to an event loop.

        If the watcher was previously attached to an event loop, then it is
        first detached before attaching to the new loop.

        Note: loop may be None.
        Nr#  ©r!   rÏ   r   r   r   Úattach_loopL  s    z AbstractChildWatcher.attach_loopc                 C   s
   t ƒ ‚dS )zlClose the watcher.

        This must be called to make sure that any underlying resource is freed.
        Nr#  rê   r   r   r   r'   V  s    zAbstractChildWatcher.closec                 C   s
   t ƒ ‚dS )zºReturn ``True`` if the watcher is active and is used by the event loop.

        Return True if the watcher is installed and ready to handle process exit
        notifications.

        Nr#  rê   r   r   r   r`   ]  s    zAbstractChildWatcher.is_activec                 C   s
   t ƒ ‚dS )zdEnter the watcher's context and allow starting new processes

        This function must return selfNr#  rê   r   r   r   Ú	__enter__f  s    zAbstractChildWatcher.__enter__c                 C   s
   t ƒ ‚dS )zExit the watcher's contextNr#  ©r!   ÚaÚbÚcr   r   r   Ú__exit__l  s    zAbstractChildWatcher.__exit__N)r»   r¼   r½   r¾   rc   r'  r)  r'   r`   r*  r/  r   r   r   r   r   "  s   
	r   c                   @   sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )r   a6  Child watcher implementation using Linux's pid file descriptors.

    This child watcher polls process file descriptors (pidfds) to await child
    process termination. In some respects, PidfdChildWatcher is a "Goldilocks"
    child watcher implementation. It doesn't require signals or threads, doesn't
    interfere with any processes launched outside the event loop, and scales
    linearly with the number of subprocesses launched by the event loop. The
    main disadvantage is that pidfds are specific to Linux, and only work on
    recent (5.3+) kernels.
    c                 C   s   d | _ i | _d S r   ©rÁ   Ú
_callbacksrê   r   r   r   r   }  s    zPidfdChildWatcher.__init__c                 C   s   | S r   r   rê   r   r   r   r*    s    zPidfdChildWatcher.__enter__c                 C   s   d S r   r   )r!   Úexc_typeÚ	exc_valueÚexc_tracebackr   r   r   r/  „  s    zPidfdChildWatcher.__exit__c                 C   s   | j d uo| j  ¡ S r   ©rÁ   Z
is_runningrê   r   r   r   r`   ‡  s    zPidfdChildWatcher.is_activec                 C   s   |   d ¡ d S r   ©r)  rê   r   r   r   r'   Š  s    zPidfdChildWatcher.closec                 C   sd   | j d ur$|d u r$| jr$t dt¡ | j ¡ D ] \}}}| j  |¡ t |¡ q.| j 	¡  || _ d S ©NzCA loop is being detached from a child watcher with pending handlers)
rÁ   r1  r,   r-   ÚRuntimeWarningÚvaluesrç   r|   r'   r/   )r!   rÏ   ÚpidfdÚ_r   r   r   r)    s    ý
zPidfdChildWatcher.attach_loopc                 G   sZ   | j  |¡}|d ur*|d ||f| j |< n,t |¡}| j || j|¡ |||f| j |< d S rµ   )r1  rM   r|   Z
pidfd_openrÁ   rÌ   Ú_do_wait)r!   rs   rH   rI   Zexistingr:  r   r   r   rc   ™  s    
z#PidfdChildWatcher.add_child_handlerc                 C   s~   | j  |¡\}}}| j |¡ zt |d¡\}}W n" tyT   d}t d|¡ Y n
0 t	|ƒ}t 
|¡ |||g|¢R Ž  d S )Nr   éÿ   zJchild process pid %d exit status already read:  will report returncode 255)r1  ÚpoprÁ   rç   r|   ÚwaitpidÚChildProcessErrorr   r  Ú_compute_returncoder'   )r!   rs   r:  rH   rI   r;  Ústatusrt   r   r   r   r<  ¢  s    ý

zPidfdChildWatcher._do_waitc                 C   sF   z| j  |¡\}}}W n ty*   Y dS 0 | j |¡ t |¡ dS )NFT)r1  r>  rN   rÁ   rç   r|   r'   )r!   rs   r:  r;  r   r   r   r'  µ  s    
z&PidfdChildWatcher.remove_child_handlerN)r»   r¼   r½   r¾   r   r*  r/  r`   r'   r)  rc   r<  r'  r   r   r   r   r   q  s   	r   c                 C   s2   t  | ¡rt  | ¡ S t  | ¡r*t  | ¡S | S d S r   )r|   ÚWIFSIGNALEDÚWTERMSIGÚ	WIFEXITEDÚWEXITSTATUS)rB  r   r   r   rA  ¿  s
    


rA  c                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚBaseChildWatcherc                 C   s   d | _ i | _d S r   r0  rê   r   r   r   r   Ï  s    zBaseChildWatcher.__init__c                 C   s   |   d ¡ d S r   r6  rê   r   r   r   r'   Ó  s    zBaseChildWatcher.closec                 C   s   | j d uo| j  ¡ S r   r5  rê   r   r   r   r`   Ö  s    zBaseChildWatcher.is_activec                 C   s
   t ƒ ‚d S r   r#  )r!   Úexpected_pidr   r   r   Ú_do_waitpidÙ  s    zBaseChildWatcher._do_waitpidc                 C   s
   t ƒ ‚d S r   r#  rê   r   r   r   Ú_do_waitpid_allÜ  s    z BaseChildWatcher._do_waitpid_allc                 C   sf   | j d ur$|d u r$| jr$t dt¡ | j d ur<| j  tj¡ || _ |d urb| tj| j	¡ |  
¡  d S r7  )rÁ   r1  r,   r-   r8  r+   r<   ÚSIGCHLDrL   Ú	_sig_chldrJ  r(  r   r   r   r)  ß  s    ý
zBaseChildWatcher.attach_loopc              
   C   s^   z|   ¡  W nL ttfy$   ‚ Y n6 tyX } z| j d|dœ¡ W Y d }~n
d }~0 0 d S )Nú$Unknown exception in SIGCHLD handler)rý   rþ   )rJ  re   rf   rg   rÁ   rÿ   r  r   r   r   rL  ó  s    þzBaseChildWatcher._sig_chldN)
r»   r¼   r½   r   r'   r`   rI  rJ  r)  rL  r   r   r   r   rG  Í  s   rG  c                       sP   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
‡  ZS )r   ad  'Safe' child watcher implementation.

    This implementation avoids disrupting other code spawning processes by
    polling explicitly each process in the SIGCHLD handler instead of calling
    os.waitpid(-1).

    This is a safe solution but it has a significant overhead when handling a
    big number of children (O(n) each time SIGCHLD is raised)
    c                    s   | j  ¡  tƒ  ¡  d S r   )r1  r/   r   r'   rê   r#   r   r   r'     s    
zSafeChildWatcher.closec                 C   s   | S r   r   rê   r   r   r   r*    s    zSafeChildWatcher.__enter__c                 C   s   d S r   r   r+  r   r   r   r/    s    zSafeChildWatcher.__exit__c                 G   s   ||f| j |< |  |¡ d S r   )r1  rI  r%  r   r   r   rc     s    z"SafeChildWatcher.add_child_handlerc                 C   s(   z| j |= W dS  ty"   Y dS 0 d S ©NTF©r1  rN   r&  r   r   r   r'    s
    z%SafeChildWatcher.remove_child_handlerc                 C   s   t | jƒD ]}|  |¡ q
d S r   ©r*   r1  rI  r&  r   r   r   rJ  $  s    z SafeChildWatcher._do_waitpid_allc                 C   sÂ   zt  |t j¡\}}W n& ty<   |}d}t d|¡ Y n.0 |dkrJd S t|ƒ}| j ¡ rjt 	d||¡ z| j
 |¡\}}W n, tyª   | j ¡ r¦tjd|dd Y n0 |||g|¢R Ž  d S )Nr=  ú8Unknown child process pid %d, will report returncode 255r   ú$process %s exited with returncode %sú'Child watcher got an unexpected pid: %rTrû   )r|   r?  ÚWNOHANGr@  r   r  rA  rÁ   ræ   ré   r1  r>  rN   )r!   rH  rs   rB  rt   rH   rI   r   r   r   rI  )  s0    þ

ÿ
ÿzSafeChildWatcher._do_waitpid)r»   r¼   r½   r¾   r'   r*  r/  rc   r'  rJ  rI  r¿   r   r   r#   r   r     s   
r   c                       sT   e Zd ZdZ‡ fdd„Z‡ fdd„Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
‡  ZS )r   aW  'Fast' child watcher implementation.

    This implementation reaps every terminated processes by calling
    os.waitpid(-1) directly, possibly breaking other code spawning processes
    and waiting for their termination.

    There is no noticeable overhead when handling a big number of children
    (O(1) each time a child terminates).
    c                    s$   t ƒ  ¡  t ¡ | _i | _d| _d S rµ   )r   r   Ú	threadingÚLockÚ_lockÚ_zombiesÚ_forksrê   r#   r   r   r   V  s    

zFastChildWatcher.__init__c                    s"   | j  ¡  | j ¡  tƒ  ¡  d S r   )r1  r/   rX  r   r'   rê   r#   r   r   r'   \  s    

zFastChildWatcher.closec                 C   s<   | j " |  jd7  _| W  d   ƒ S 1 s.0    Y  d S )Nr   )rW  rY  rê   r   r   r   r*  a  s    zFastChildWatcher.__enter__c                 C   st   | j N |  jd8  _| js"| js2W d   ƒ d S t| jƒ}| j ¡  W d   ƒ n1 sZ0    Y  t d|¡ d S )Nr   z5Caught subprocesses termination from unknown pids: %s)rW  rY  rX  rB   r/   r   r  )r!   r,  r-  r.  Zcollateral_victimsr   r   r   r/  g  s    
(þzFastChildWatcher.__exit__c              	   G   s|   | j P z| j |¡}W n. tyF   ||f| j|< Y W d   ƒ d S 0 W d   ƒ n1 s\0    Y  |||g|¢R Ž  d S r   )rW  rX  r>  rN   r1  )r!   rs   rH   rI   rt   r   r   r   rc   u  s    2z"FastChildWatcher.add_child_handlerc                 C   s(   z| j |= W dS  ty"   Y dS 0 d S rN  rO  r&  r   r   r   r'  ƒ  s
    z%FastChildWatcher.remove_child_handlerc              	   C   s  zt  dt j¡\}}W n ty*   Y d S 0 |dkr8d S t|ƒ}| jŒ z| j |¡\}}W nN tyª   | j	r¢|| j
|< | j ¡ r’t d||¡ Y W d   ƒ q d }Y n0 | j ¡ rÄt d||¡ W d   ƒ n1 sØ0    Y  |d u rút d||¡ q |||g|¢R Ž  q d S )Nr5   r   z,unknown process %s exited with returncode %srR  z8Caught subprocess termination from unknown pid: %d -> %d)r|   r?  rT  r@  rA  rW  r1  r>  rN   rY  rX  rÁ   ræ   r   ré   r  )r!   rs   rB  rt   rH   rI   r   r   r   rJ  Š  s:    

þ

ÿ"þz FastChildWatcher._do_waitpid_all)r»   r¼   r½   r¾   r   r'   r*  r/  rc   r'  rJ  r¿   r   r   r#   r   r   L  s   	r   c                   @   sh   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )r   a~  A watcher that doesn't require running loop in the main thread.

    This implementation registers a SIGCHLD signal handler on
    instantiation (which may conflict with other code that
    install own handler for this signal).

    The solution is safe but it has a significant overhead when
    handling a big number of processes (*O(n)* each time a
    SIGCHLD is received).
    c                 C   s   i | _ d | _d S r   )r1  Ú_saved_sighandlerrê   r   r   r   r   È  s    zMultiLoopChildWatcher.__init__c                 C   s
   | j d uS r   )rZ  rê   r   r   r   r`   Ì  s    zMultiLoopChildWatcher.is_activec                 C   sT   | j  ¡  | jd u rd S t tj¡}|| jkr:t d¡ nt tj| j¡ d | _d S )Nz+SIGCHLD handler was changed by outside code)	r1  r/   rZ  r<   Ú	getsignalrK  rL  r   r  )r!   rR   r   r   r   r'   Ï  s    


zMultiLoopChildWatcher.closec                 C   s   | S r   r   rê   r   r   r   r*  Û  s    zMultiLoopChildWatcher.__enter__c                 C   s   d S r   r   ©r!   r2  Úexc_valÚexc_tbr   r   r   r/  Þ  s    zMultiLoopChildWatcher.__exit__c                 G   s&   t  ¡ }|||f| j|< |  |¡ d S r   )r   Úget_running_loopr1  rI  )r!   rs   rH   rI   rÏ   r   r   r   rc   á  s    z'MultiLoopChildWatcher.add_child_handlerc                 C   s(   z| j |= W dS  ty"   Y dS 0 d S rN  rO  r&  r   r   r   r'  è  s
    z*MultiLoopChildWatcher.remove_child_handlerc                 C   sN   | j d urd S t tj| j¡| _ | j d u r<t d¡ tj| _ t tjd¡ d S )NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)rZ  r<   rK  rL  r   r  rQ   rD   r(  r   r   r   r)  ï  s    


z!MultiLoopChildWatcher.attach_loopc                 C   s   t | jƒD ]}|  |¡ q
d S r   rP  r&  r   r   r   rJ     s    z%MultiLoopChildWatcher._do_waitpid_allc           	      C   sà   zt  |t j¡\}}W n* ty@   |}d}t d|¡ d}Y n0 |dkrNd S t|ƒ}d}z| j |¡\}}}W n" t	y’   tjd|dd Y nJ0 | 
¡ r¬t d||¡ n0|rÆ| ¡ rÆt d	||¡ |j|||g|¢R Ž  d S )
Nr=  rQ  Fr   TrS  rû   ú%Loop %r that handles pid %r is closedrR  )r|   r?  rT  r@  r   r  rA  r1  r>  rN   Ú	is_closedræ   ré   rr   )	r!   rH  rs   rB  rt   Z	debug_logrÏ   rH   rI   r   r   r   rI    s6    þ
ÿÿz!MultiLoopChildWatcher._do_waitpidc              	   C   sH   z|   ¡  W n6 ttfy$   ‚ Y n  tyB   tjddd Y n0 d S )NrM  Trû   )rJ  re   rf   rg   r   r  )r!   r   r   r   r   r   rL  )  s    zMultiLoopChildWatcher._sig_chldN)r»   r¼   r½   r¾   r   r`   r'   r*  r/  rc   r'  r)  rJ  rI  rL  r   r   r   r   r   µ  s   %r   c                   @   sn   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e
jfdd„Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r   aA  Threaded child watcher implementation.

    The watcher uses a thread per process
    for waiting for the process finish.

    It doesn't require subscription on POSIX signal
    but a thread creation is not free.

    The watcher has O(1) complexity, its performance doesn't depend
    on amount of spawn processes.
    c                 C   s   t  d¡| _i | _d S rµ   )Ú	itertoolsr¢   Ú_pid_counterÚ_threadsrê   r   r   r   r   ?  s    zThreadedChildWatcher.__init__c                 C   s   dS r  r   rê   r   r   r   r`   C  s    zThreadedChildWatcher.is_activec                 C   s   |   ¡  d S r   )Ú_join_threadsrê   r   r   r   r'   F  s    zThreadedChildWatcher.closec                 C   s.   dd„ t | j ¡ ƒD ƒ}|D ]}| ¡  qdS )z%Internal: Join all non-daemon threadsc                 S   s   g | ]}|  ¡ r|js|‘qS r   )Úis_aliveÚdaemon©Ú.0Úthreadr   r   r   Ú
<listcomp>K  s   ÿz6ThreadedChildWatcher._join_threads.<locals>.<listcomp>N)r*   rd  r9  rà   )r!   Úthreadsrj  r   r   r   re  I  s    z"ThreadedChildWatcher._join_threadsc                 C   s   | S r   r   rê   r   r   r   r*  P  s    zThreadedChildWatcher.__enter__c                 C   s   d S r   r   r\  r   r   r   r/  S  s    zThreadedChildWatcher.__exit__c                 C   s6   dd„ t | j ¡ ƒD ƒ}|r2|| j› dt| d d S )Nc                 S   s   g | ]}|  ¡ r|‘qS r   )rf  rh  r   r   r   rk  W  s   ÿz0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr%   )r*   rd  r9  r$   r.   )r!   r÷   rl  r   r   r   rø   V  s    þzThreadedChildWatcher.__del__c                 G   sF   t  ¡ }tj| jdt| jƒ› ||||fdd}|| j|< | ¡  d S )Nzwaitpid-T)ÚtargetÚnamerI   rg  )	r   r_  rU  ÚThreadrI  Únextrc  rd  Ústart)r!   rs   rH   rI   rÏ   rj  r   r   r   rc   ^  s    
ý
z&ThreadedChildWatcher.add_child_handlerc                 C   s   dS r  r   r&  r   r   r   r'  g  s    z)ThreadedChildWatcher.remove_child_handlerc                 C   s   d S r   r   r(  r   r   r   r)  m  s    z ThreadedChildWatcher.attach_loopc                 C   s˜   zt  |d¡\}}W n& ty:   |}d}t d|¡ Y n 0 t|ƒ}| ¡ rZt d||¡ | ¡ rrt d||¡ n|j	|||g|¢R Ž  | j
 |¡ d S )Nr   r=  rQ  rR  r`  )r|   r?  r@  r   r  rA  ræ   ré   ra  rr   rd  r>  )r!   rÏ   rH  rH   rI   rs   rB  rt   r   r   r   rI  p  s$    þ
ÿz ThreadedChildWatcher._do_waitpidN)r»   r¼   r½   r¾   r   r`   r'   re  r*  r/  r,   r-   rø   rc   r'  r)  rI  r   r   r   r   r   2  s   	r   c                       sH   e Zd ZdZeZ‡ fdd„Zdd„ Z‡ fdd„Zdd	„ Z	d
d„ Z
‡  ZS )Ú_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.c                    s   t ƒ  ¡  d | _d S r   )r   r   Ú_watcherrê   r#   r   r   r     s    
z$_UnixDefaultEventLoopPolicy.__init__c                 C   s\   t jB | jd u r:tƒ | _t ¡ t ¡ u r:| j | jj	¡ W d   ƒ n1 sN0    Y  d S r   )
r   rW  rs  r   rU  Úcurrent_threadÚmain_threadr)  Ú_localrÁ   rê   r   r   r   Ú_init_watcher“  s
    
z)_UnixDefaultEventLoopPolicy._init_watcherc                    s6   t ƒ  |¡ | jdur2t ¡ t ¡ u r2| j |¡ dS )zÑSet the event loop.

        As a side effect, if a child watcher was set before, then calling
        .set_event_loop() from the main thread will call .attach_loop(loop) on
        the child watcher.
        N)r   Úset_event_looprs  rU  rt  ru  r)  r(  r#   r   r   rx  š  s
    
ÿz*_UnixDefaultEventLoopPolicy.set_event_loopc                 C   s   | j du r|  ¡  | j S )z~Get the watcher for child processes.

        If not yet set, a ThreadedChildWatcher object is automatically created.
        N)rs  rw  rê   r   r   r   r_   ¨  s    
z-_UnixDefaultEventLoopPolicy.get_child_watcherc                 C   s   | j dur| j  ¡  || _ dS )z$Set the watcher for child processes.N)rs  r'   )r!   ro   r   r   r   Úset_child_watcher²  s    

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r»   r¼   r½   r¾   r   Z_loop_factoryr   rw  rx  r_   ry  r¿   r   r   r#   r   rr  ‹  s   
rr  )3r¾   rF   r›   rb  r|   rÝ   r<   r~   r   r  r(   rU  r,   Ú r   r   r   r   r   r   r	   r
   r   r   Úlogr   Ú__all__r  ÚImportErrorr   ZBaseSelectorEventLoopr   ZReadTransportrV   Z_FlowControlMixinZWriteTransportr]   ZBaseSubprocessTransportrb   r   r   rA  rG  r   r   r   r   ZBaseDefaultEventLoopPolicyrr  r   r   r   r   r   r   Ú<module>   sb   	
    	ÿ NON5Ji}Y2