HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/asyncio/__pycache__/unix_events.cpython-310.opt-2.pyc
o

�i���@s�	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZdZe	jdkr~ed��dd�Zdd�ZGdd�dej�ZGdd�dej �Z!Gdd�dej"ej#�Z$Gdd�dej%�Z&Gdd�d�Z'Gdd �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*e'�Z-Gd+d,�d,ej.�Z/eZ0e/Z1dS)-�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 WindowscCs	dS�N�)�signum�framerr�0/usr/local/lib/python3.10/asyncio/unix_events.py�_sighandler_noop*srcCs$zt�|�WSty|YSwr)�os�waitstatus_to_exitcode�
ValueError)�statusrrrr/s
�rcs�eZdZ	d(�fdd�	Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z			d)dd�Z
		d)dd�Z	d(dd�Zdd�Z
	d(ddddd�dd�Z	d(dddddd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z�ZS)*�_UnixSelectorEventLoopNcst��|�i|_dSr)�super�__init__�_signal_handlers)�self�selector��	__class__rrr#?�
z_UnixSelectorEventLoop.__init__cs`t���t��st|j�D]}|�|�qdS|jr.tjd|�d�t	|d�|j�
�dSdS)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,Cs
���z_UnixSelectorEventLoop.closecCs|D]
}|sq|�|�qdSr)�_handle_signal)r%�datarrrr�_process_self_dataQs
�z)_UnixSelectorEventLoop._process_self_datac
Gs0	t�|�st�|�rtd��|�|�|��z
t�|j�	��Wnt
tfy6}ztt
|���d}~wwt�|||d�}||j|<zt�|t�t�|d�WdSty�}z8|j|=|js�zt�d�Wnt
tfy�}zt�d|�WYd}~nd}~ww|jtjkr�td|�d����d}~ww)Nz3coroutines cannot be used with add_signal_handler()F����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)rZiscoroutineZiscoroutinefunction�	TypeError�
_check_signal�
_check_closed�signal�
set_wakeup_fdZ_csock�filenor�OSError�RuntimeError�strr�Handler$r�siginterruptr
�info�errno�EINVAL)r%r6�callback�args�exc�handleZnexcrrr�add_signal_handlerXs@
�
��
����z)_UnixSelectorEventLoop.add_signal_handlercCs<	|j�|�}|dur
dS|jr|�|�dS|�|�dSr)r$�getZ
_cancelledr0Z_add_callback_signalsafe)r%r6rOrrrr7�sz%_UnixSelectorEventLoop._handle_signalc
Cs�	|�|�z|j|=Wn
tyYdSw|tjkr tj}ntj}zt�||�WntyF}z|jtj	krAt
d|�d����d}~ww|jsnzt�d�WdSttfym}z
t
�d|�WYd}~dSd}~wwdS)NFr<r=r:r;T)r?r$�KeyErrorrA�SIGINT�default_int_handler�SIG_DFLrDrJrKrErBrr
rI)r%r6�handlerrNrrrr0�s8
�
�����z,_UnixSelectorEventLoop.remove_signal_handlercCs8	t|t�s
td|����|t��vrtd|����dS)Nzsig must be an int, not zinvalid signal number )�
isinstance�intr>rA�
valid_signalsrr5rrrr?�s
�z$_UnixSelectorEventLoop._check_signalcC�t|||||�Sr)�_UnixReadPipeTransport�r%�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport��z0_UnixSelectorEventLoop._make_read_pipe_transportcCrZr)�_UnixWritePipeTransportr\rrr�_make_write_pipe_transport�rbz1_UnixSelectorEventLoop._make_write_pipe_transportc	

�s��t���U}
|
��std��|��}t||||||||f||d�|	��}|
�|��|j|�z|IdHWnt	t
fy?�tyQ|��|�
�IdH�wWd�|S1s]wY|S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)r_r`)r�get_child_watcher�	is_activerE�
create_future�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback�
SystemExit�KeyboardInterrupt�
BaseExceptionr,�_wait)
r%r^rM�shell�stdin�stdout�stderr�bufsizer`�kwargs�watcherr_�transprrr�_make_subprocess_transport�s:�

���
���
��z1_UnixSelectorEventLoop._make_subprocess_transportcCs|�|j|j|�dSr)�call_soon_threadsafe�	call_soonZ_process_exited)r%�pid�
returncodervrrrrj�sz._UnixSelectorEventLoop._child_watcher_callback)�ssl�sock�server_hostname�ssl_handshake_timeoutc	�s�|r|durtd��n|durtd��|durtd��|durO|dur(td��t�|�}t�tjtjd�}z|�d�|�||�IdHWn(|���|durWtd��|j	tjksc|j
tjkrjtd|����|�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 )r)rr�fspath�socket�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr,�family�typeZ_create_connection_transport)	r%�protocol_factory�pathr|r}r~r�	transportr^rrr�create_unix_connection�sN�����

�
�z-_UnixSelectorEventLoop.create_unix_connection�dT)r}�backlogr|r�
start_servingc
�s��t|t�r
td��|dur|std��|dur�|dur td��t�|�}t�tjtj�}|ddvrezt	�
t�	|�j�rBt�|�Wn!t
yLYntyd}z
t�d||�WYd}~nd}~wwz|�|�WnFty�}	z|��|	jtjkr�d|�d�}
ttj|
�d��d}	~	w|���|dur�td	��|jtjks�|jtjkr�td
|����|�d�t�||g||||�}|r�|��t�d�IdH|S)Nz*ssl argument must be an SSLContext or Noner�r�r)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedr�F)rW�boolr>rrr�r�r�r��stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorrDr
�error�bindr,rJZ
EADDRINUSEr�r�r�rZServerZ_start_servingr�sleep)r%r�r�r}r�r|rr��errrN�msgZserverrrr�create_unix_serversp�
��

�������
�z)_UnixSelectorEventLoop.create_unix_serverc

�s��ztjWntyt�d��wz|��}Wnttjfy-}zt�d��d}~wwzt�|�j	}Wnt
yBt�d��w|rG|n|}|sMdS|��}	|�|	d|||||d�|	IdHS)Nzos.sendfile() is not availableznot a regular filer)
r�sendfile�AttributeErrorr�SendfileNotAvailableErrorrC�io�UnsupportedOperation�fstat�st_sizerDrg�_sock_sendfile_native_impl)
r%r}�file�offset�countrCr��fsize�	blocksize�futrrr�_sock_sendfile_nativeUs6�
��
��
��
z,_UnixSelectorEventLoop._sock_sendfile_nativec	Cs*|��}	|dur
|�|�|��r|�|||�dS|r2||}|dkr2|�|||�|�|�dSz
t�|	|||�}
Wn�ttfya|durO|�	||�|�
|	|j||	||||||�
YdSty�}zK|dur�|j
t
jkr�t|�tur�tdt
j�}||_|}|dkr�t�d�}
|�|||�|�|
�n|�|||�|�|�WYd}~dSWYd}~dSd}~wttfy��ty�}z|�|||�|�|�WYd}~dSd}~ww|
dkr�|�|||�|�|�dS||
7}||
7}|du�r|�	||�|�
|	|j||	||||||�
dS)Nrzsocket is not connectedzos.sendfile call failed)rC�
remove_writer�	cancelled�_sock_sendfile_update_filepos�
set_resultrr��BlockingIOError�InterruptedError�_sock_add_cancellation_callbackZ
add_writerr�rDrJZENOTCONNr��ConnectionError�	__cause__rr��
set_exceptionrkrlrm)r%r�Z
registered_fdr}rCr�r�r��
total_sent�fd�sentrN�new_excr�rrrr�lst


�������
�z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs |dkrt�||tj�dSdS�Nr)r�lseek�SEEK_SET)r%rCr�r�rrrr��s�z4_UnixSelectorEventLoop._sock_sendfile_update_fileposcs��fdd�}|�|�dS)Ncs.|��r���}|dkr��|�dSdSdS)Nr:)r�rCr�)r�r��r%r}rr�cb�s�zB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb)�add_done_callback)r%r�r}r�rr�rr��sz6_UnixSelectorEventLoop._sock_add_cancellation_callbackr�NN)�__name__�
__module__�__qualname__r#r,r9rPr7r0r?rardrwrjr�r�r�r�r�r��
__classcell__rrr'rr!9sD-
 
�
�
���.��CFr!cs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jfdd�Zddd�Zdd�Zdd�Z�ZS) r[iNcs�t��|�||jd<||_||_|��|_||_d|_d|_	t
�|j�j}t
�|�sBt
�|�sBt
�|�sBd|_d|_d|_td��t
�|jd�|j�|jj|�|j�|jj|j|j�|durm|j�tj|d�dSdS)Nr]Fz)Pipe transport is for pipes/sockets only.)r"r#�_extra�_loop�_piperC�_fileno�	_protocol�_closing�_pausedrr�r�r��S_ISFIFOr��S_ISCHRr�set_blockingry�connection_made�_add_reader�_read_readyr	�_set_result_unless_cancelled)r%�loopr]r^r_r`�moder'rrr#�s8


���
��z_UnixReadPipeTransport.__init__cCs�|jjg}|jdur|�d�n|jr|�d�|�d|j���t|jdd�}|jdurH|durHt�	||jt
j�}|rB|�d�n|�d�n|jdurS|�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%rIr&r�rrr�__repr__�s$



�

z_UnixReadPipeTransport.__repr__c
Cs�z
t�|j|j�}Wn$ttfyYdSty.}z
|�|d�WYd}~dSd}~ww|r9|j�	|�dS|j
��rDt�
d|�d|_|j
�|j�|j
�|jj�|j
�|jd�dS)Nz"Fatal read error on pipe transport�%r was closed by peerT)r�readr��max_sizer�r�rD�_fatal_errorr�Z
data_receivedr��	get_debugr
rIr��_remove_readerryZeof_received�_call_connection_lost)r%r8rNrrrr��s ��
z"_UnixReadPipeTransport._read_readycCsB|js|jrdSd|_|j�|j�|j��rt�d|�dSdS)NTz%r pauses reading)r�r�r�r�r�r�r
�debug�r%rrr�
pause_readings
�z$_UnixReadPipeTransport.pause_readingcCsF|js|jsdSd|_|j�|j|j�|j��r!t�d|�dSdS)NFz%r resumes reading)	r�r�r�r�r�r�r�r
r�r�rrr�resume_readings
�z%_UnixReadPipeTransport.resume_readingcC�
||_dSr�r��r%r^rrr�set_protocol�
z#_UnixReadPipeTransport.set_protocolcC�|jSrr�r�rrr�get_protocol�z#_UnixReadPipeTransport.get_protocolcCr�r�r�r�rrr�
is_closingr�z!_UnixReadPipeTransport.is_closingcCs|js
|�d�dSdSr)r��_closer�rrrr,!s�z_UnixReadPipeTransport.closecC�0|jdur|d|��t|d�|j��dSdS�Nzunclosed transport r*�r�r3r,�r%�_warnrrr�__del__%�
�z_UnixReadPipeTransport.__del__�Fatal error on pipe transportcCsZt|t�r|jtjkr|j��rtjd||dd�n|j�||||j	d��|�
|�dS�Nz%r: %sT��exc_info)�message�	exceptionr�r^)rWrDrJZEIOr�r�r
r��call_exception_handlerr�r��r%rNrrrrr�*s
��z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j�|j�|j�|j|�dS�NT)r�r�r�r�ryr��r%rNrrrr�8sz_UnixReadPipeTransport._closecC�Nz|j�|�W|j��d|_d|_d|_dS|j��d|_d|_d|_wr�r�Zconnection_lostr�r,r�r
rrrr�=�


�z,_UnixReadPipeTransport._call_connection_lostr��r)r�r�r�r�r#r�r�r�r�r�r�r�r,r1r2rr�r�r�r�rrr'rr[�s
r[cs�eZdZd%�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejfdd�Zdd�Zd&dd �Zd'd!d"�Zd#d$�Z�ZS)(rcNc
st��||�||jd<||_|��|_||_t�|_d|_	d|_
t�|j�j
}t�|�}t�|�}t�|�}	|sJ|sJ|	sJd|_d|_d|_td��t�|jd�|j�|jj|�|	sd|rptj�d�sp|j�|jj|j|j�|dur|j�tj|d�dSdS)Nr]rFz?Pipe transport is only for pipes, sockets and character devices�aix)r"r#r�r�rCr�r��	bytearray�_buffer�
_conn_lostr�rr�r�r�r�r�r�rr�r�ryr�r-�platform�
startswithr�r�r	r�)
r%r�r]r^r_r`r�Zis_char�is_fifo�	is_socketr'rrr#Js8




�
��z _UnixWritePipeTransport.__init__cCs�|jjg}|jdur|�d�n|jr|�d�|�d|j���t|jdd�}|jdurT|durTt�	||jt
j�}|rB|�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��EVENT_WRITE�get_write_buffer_sizer�r�)r%rIr&r�rsrrrr�os(



�


z _UnixWritePipeTransport.__repr__cCs
t|j�Sr)�lenrr�rrrr�r�z-_UnixWritePipeTransport.get_write_buffer_sizecCs8|j��rt�d|�|jr|�t��dS|��dS)Nr�)r�r�r
rIrr��BrokenPipeErrorr�rrrr��s

z#_UnixWritePipeTransport._read_readyc
Cs&t|t�r	t|�}|s
dS|js|jr'|jtjkrt�d�|jd7_dS|j	s�z	t
�|j|�}Wn5t
tfy@d}Yn)ttfyI�tyh}z|jd7_|�|d�WYd}~dSd}~ww|t|�krqdS|dkr}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)rWr�
memoryviewrr�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningrr�writer�r�r�rkrlrmr�rr�Z_add_writer�_write_readyZ_maybe_pause_protocol)r%r8�nrNrrrr!�s:

��z_UnixWritePipeTransport.writec
Csz
t�|j|j�}Wn@ttfyYdSttfy�tyJ}z |j�	�|j
d7_
|j�|j�|�
|d�WYd}~dSd}~ww|t|j�krs|j�	�|j�|j�|��|jrq|j�|j�|�d�dS|dkr|jd|�=dSdS)Nrrr)rr!r�rr�r�rkrlrmr4rr��_remove_writerr�rZ_maybe_resume_protocolr�r�r�)r%r#rNrrrr"�s0
��

�z$_UnixWritePipeTransport._write_readycC�dSrrr�rrr�
can_write_eof��z%_UnixWritePipeTransport.can_write_eofcCs<|jrdSd|_|js|j�|j�|j�|jd�dSdSr)r�rr�r�r�ryr�r�rrr�	write_eof�s�z!_UnixWritePipeTransport.write_eofcCr�rr�r�rrrr��r�z$_UnixWritePipeTransport.set_protocolcCr�rr�r�rrrr��r�z$_UnixWritePipeTransport.get_protocolcCr�rr�r�rrrr��r�z"_UnixWritePipeTransport.is_closingcCs$|jdur|js|��dSdSdSr)r�r�r(r�rrrr,�s�z_UnixWritePipeTransport.closecCr�r�r�rrrrr�rz_UnixWritePipeTransport.__del__cC�|�d�dSr)r�r�rrr�abort��z_UnixWritePipeTransport.abortrcCsNt|t�r|j��rtjd||dd�n|j�||||jd��|�|�dSr)	rWrDr�r�r
r�r
r�r�rrrrr��s

��z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr
|j�|j�|j��|j�|j�|j�|j|�dSr)	r�rr�r$r�r4r�ryr�r
rrrr�s
z_UnixWritePipeTransport._closecCrrrr
rrrr�
rz-_UnixWritePipeTransport._call_connection_lostr�rr)r�r�r�r#r�rr�r!r"r&r(r�r�r�r,r1r2rr*r�r�r�r�rrr'rrcGs$%	#	

rcc@seZdZdd�ZdS)rhc		Ks�d}|tjkrtj�d�rt��\}}z7tj|f||||d|d�|��|_|dur:|�	�t
|��d|d�|j_d}W|durI|�	�|�	�dSdS|durX|�	�|�	�ww)NrF)rorprqrr�universal_newlinesrs�wb)�	buffering)
�
subprocess�PIPEr-rrr��
socketpair�Popen�_procr,r��detachrp)	r%rMrorprqrrrsrtZstdin_wrrr�_starts0�����
�z_UnixSubprocessTransport._startN)r�r�r�r5rrrrrhsrhc@sFeZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rcG�	t��r��NotImplementedError�r%rzrLrMrrrriCsz&AbstractChildWatcher.add_child_handlercCr6rr7�r%rzrrr�remove_child_handlerNsz)AbstractChildWatcher.remove_child_handlercCr6rr7�r%r�rrr�attach_loopVsz AbstractChildWatcher.attach_loopcCr6rr7r�rrrr,`szAbstractChildWatcher.closecCr6rr7r�rrrrfgszAbstractChildWatcher.is_activecCr6rr7r�rrr�	__enter__pszAbstractChildWatcher.__enter__cCr6rr7�r%�a�b�crrr�__exit__vszAbstractChildWatcher.__exit__N)
r�r�r�rir;r=r,rfr>rCrrrrr,s
	rc@sVeZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)rcC�d|_i|_dSr�r��
_callbacksr�rrrr#��
zPidfdChildWatcher.__init__cC�|Srrr�rrrr>�r'zPidfdChildWatcher.__enter__cC�dSrr)r%�exc_type�	exc_value�
exc_tracebackrrrrC�r'zPidfdChildWatcher.__exit__cC�|jduo	|j��Sr�r�Z
is_runningr�rrrrf��zPidfdChildWatcher.is_activecCr)r�r=r�rrrr,�r+zPidfdChildWatcher.closecCsd|jdur|dur|jrt�dt�|j��D]\}}}|j�|�t�|�q|j�	�||_dS�NzCA loop is being detached from a child watcher with pending handlers)
r�rFr1r2�RuntimeWarning�valuesr�rr,r4)r%r��pidfd�_rrrr=�s�

zPidfdChildWatcher.attach_loopcGs\|j�|�}|dur|d||f|j|<dSt�|�}|j�||j|�|||f|j|<dSr�)rFrQrZ
pidfd_openr�r��_do_wait)r%rzrLrMZexistingrTrrrri�s
z#PidfdChildWatcher.add_child_handlercCs~|j�|�\}}}|j�|�z
t�|d�\}}Wnty*d}t�d|�Ynwt	|�}t�
|�|||g|�R�dS)Nr�zJchild process pid %d exit status already read:  will report returncode 255)rF�popr�r�r�waitpid�ChildProcessErrorr
r rr,)r%rzrTrLrMrUr r{rrrrV�s��	
zPidfdChildWatcher._do_waitcCsFz|j�|�\}}}Wn
tyYdSw|j�|�t�|�dS)NFT)rFrXrRr�r�rr,)r%rzrTrUrrrr;�s�
z&PidfdChildWatcher.remove_child_handlerN)r�r�r�r#r>rCrfr,r=rirVr;rrrrr{s	rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCrDrrEr�rrrr#�rGzBaseChildWatcher.__init__cCr)rrPr�rrrr,�r+zBaseChildWatcher.closecCrMrrNr�rrrrf�rOzBaseChildWatcher.is_activecC�t��rr7)r%�expected_pidrrr�_do_waitpid�r�zBaseChildWatcher._do_waitpidcCr\rr7r�rrr�_do_waitpid_all�r�z BaseChildWatcher._do_waitpid_allcCsj|jdur|dur|jrt�dt�|jdur|j�tj�||_|dur3|�tj|j	�|�
�dSdSrQ)r�rFr1r2rRr0rA�SIGCHLDrP�	_sig_chldr_r<rrrr=�s�
�zBaseChildWatcher.attach_loopc
CsZz|��WdSttfy�ty,}z|j�d|d��WYd}~dSd}~ww)N�$Unknown exception in SIGCHLD handler)rr	)r_rkrlrmr�r
r
rrrra�s���zBaseChildWatcher._sig_chldN)
r�r�r�r#r,rfr^r_r=rarrrrr[�sr[csNeZdZ	�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs|j��t���dSr)rFr4r"r,r�r'rrr,	s
zSafeChildWatcher.closecCrHrrr�rrrr>
r'zSafeChildWatcher.__enter__cCrIrrr?rrrrCr'zSafeChildWatcher.__exit__cGs||f|j|<|�|�dSr)rFr^r9rrrrisz"SafeChildWatcher.add_child_handlercC�$z|j|=WdStyYdSw�NTF�rFrRr:rrrr;��z%SafeChildWatcher.remove_child_handlercC�t|j�D]}|�|�qdSr�r/rFr^r:rrrr_ s�z SafeChildWatcher._do_waitpid_allcCs�zt�|tj�\}}Wnty|}d}t�d|�Ynw|dkr%dSt|�}|j��r5t�	d||�z
|j
�|�\}}WntyY|j��rVtjd|dd�YdSYdSw|||g|�R�dS)NrW�8Unknown child process pid %d, will report returncode 255r�$process %s exited with returncode %s�'Child watcher got an unexpected pid: %rTr)
rrY�WNOHANGrZr
r rr�r�r�rFrXrR)r%r]rzr r{rLrMrrrr^%s6��	
�
���zSafeChildWatcher._do_waitpid)r�r�r�r,r>rCrir;r_r^r�rrr'rr�s
rcsReZdZ	�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs$t���t��|_i|_d|_dSr�)r"r#�	threading�Lock�_lock�_zombies�_forksr�r'rrr#Rs


zFastChildWatcher.__init__cs"|j��|j��t���dSr)rFr4rpr"r,r�r'rrr,Xs

zFastChildWatcher.closecCs<|j�|jd7_|Wd�S1swYdS)Nr)rorqr�rrrr>]s$�zFastChildWatcher.__enter__cCsv|j�(|jd8_|js|js	Wd�dSt|j�}|j��Wd�n1s.wYt�d|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)rorqrprFr4r
r )r%r@rArBZcollateral_victimsrrrrCcs�
�	�zFastChildWatcher.__exit__c	Gs||j�(z|j�|�}Wnty#||f|j|<YWd�dSwWd�n1s.wY|||g|�R�dSr)rorprXrRrF)r%rzrLrMr{rrrriqs���	z"FastChildWatcher.add_child_handlercCrcrdrer:rrrr;rfz%FastChildWatcher.remove_child_handlerc	Cs	zt�dtj�\}}Wn
tyYdSw|dkrdSt|�}|j�Fz
|j�|�\}}Wn'tyV|j	rR||j
|<|j��rJt
�d||�YWd�qd}Yn
w|j��rct
�d||�Wd�n1smwY|dur~t
�d||�n	|||g|�R�q)NTr:rz,unknown process %s exited with returncode %srjz8Caught subprocess termination from unknown pid: %d -> %d)rrYrlrZrrorFrXrRrqrpr�r�r
r�r )r%rzr r{rLrMrrrr_�sH�

��
�
�����z FastChildWatcher._do_waitpid_all)r�r�r�r#r,r>rCrir;r_r�rrr'rrHs	rc@sfeZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rcCsi|_d|_dSr)rF�_saved_sighandlerr�rrrr#�rGzMultiLoopChildWatcher.__init__cCs
|jduSr)rrr�rrrrf�r�zMultiLoopChildWatcher.is_activecCsT|j��|jdurdSt�tj�}||jkrt�d�nt�tj|j�d|_dS)Nz+SIGCHLD handler was changed by outside code)	rFr4rrrA�	getsignalr`rar
r )r%rVrrrr,�s



zMultiLoopChildWatcher.closecCrHrrr�rrrr>�r'zMultiLoopChildWatcher.__enter__cCrIrr�r%rJ�exc_val�exc_tbrrrrC�r'zMultiLoopChildWatcher.__exit__cGs&t��}|||f|j|<|�|�dSr)r�get_running_looprFr^)r%rzrLrMr�rrrri�sz'MultiLoopChildWatcher.add_child_handlercCrcrdrer:rrrr;�rfz*MultiLoopChildWatcher.remove_child_handlercCsN|jdurdSt�tj|j�|_|jdurt�d�tj|_t�tjd�dS)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)rrrAr`rar
r rUrHr<rrrr=�s


z!MultiLoopChildWatcher.attach_loopcCrgrrhr:rrrr_�s�z%MultiLoopChildWatcher._do_waitpid_allc	Cs�zt�|tj�\}}Wnty |}d}t�d|�d}Yn
w|dkr'dSt|�}d}z|j�|�\}}}Wnt	yJtjd|dd�YdSw|�
�rXt�d||�dS|re|��ret�d	||�|j
|||g|�R�dS)
NrWriFrTrkr�%Loop %r that handles pid %r is closedrj)rrYrlrZr
r rrFrXrR�	is_closedr�r�rx)	r%r]rzr r{Z	debug_logr�rLrMrrrr^s:��
���z!MultiLoopChildWatcher._do_waitpidc	CsDz|��WdSttfy�ty!tjddd�YdSw)NrbTr)r_rkrlrmr
r )r%rrrrrra%s�zMultiLoopChildWatcher._sig_chldN)r�r�r�r#rfr,r>rCrir;r=r_r^rarrrrr�s%rc@sleZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
fd
d�Zdd�Zdd�Z
dd�Zdd�ZdS)rcCst�d�|_i|_dSr�)�	itertoolsr��_pid_counter�_threadsr�rrrr#;r)zThreadedChildWatcher.__init__cCr%rrr�rrrrf?r'zThreadedChildWatcher.is_activecCs|��dSr)�
_join_threadsr�rrrr,BszThreadedChildWatcher.closecCs0	dd�t|j���D�}|D]}|��qdS)NcSsg|]}|��r|js|�qSr)�is_alive�daemon��.0�threadrrr�
<listcomp>Gs
�
�z6ThreadedChildWatcher._join_threads.<locals>.<listcomp>)r/r|rSr�)r%�threadsr�rrrr}Es

�z"ThreadedChildWatcher._join_threadscCrHrrr�rrrr>Lr'zThreadedChildWatcher.__enter__cCrIrrrtrrrrCOr'zThreadedChildWatcher.__exit__cCs:dd�t|j���D�}|r||j�d�t|d�dSdS)NcSsg|]}|��r|�qSr)r~r�rrrr�Ss
�z0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr*)r/r|rSr(r3)r%rr�rrrrRs
��zThreadedChildWatcher.__del__cGsFt��}tj|jdt|j���||||fdd�}||j|<|��dS)Nzwaitpid-T)�target�namerMr)	rrwrm�Threadr^�nextr{r|�start)r%rzrLrMr�r�rrrriZs
�
z&ThreadedChildWatcher.add_child_handlercCr%rrr:rrrr;csz)ThreadedChildWatcher.remove_child_handlercCrIrrr<rrrr=ir'z ThreadedChildWatcher.attach_loopcCs�z
t�|d�\}}Wnty|}d}t�d|�Ynwt|�}|��r-t�d||�|��r9t�d||�n|j	|||g|�R�|j
�|�dS)NrrWrirjrx)rrYrZr
r rr�r�ryrxr|rX)r%r�r]rLrMrzr r{rrrr^ls&��	�z ThreadedChildWatcher._do_waitpidN)r�r�r�r#rfr,r}r>rCr1r2rrir;r=r^rrrrr.s	rcsFeZdZ	eZ�fdd�Zdd�Z�fdd�Zdd�Zd	d
�Z	�Z
S)�_UnixDefaultEventLoopPolicycst���d|_dSr)r"r#�_watcherr�r'rrr#�s

z$_UnixDefaultEventLoopPolicy.__init__cCs~tj�2|jdur%t�|_t��t��ur-|j�|jj	�Wd�dSWd�dSWd�dS1s8wYdSr)
rror�rrm�current_thread�main_threadr=�_localr�r�rrr�
_init_watcher�s
��"�z)_UnixDefaultEventLoopPolicy._init_watchercs@	t��|�|jdurt��t��ur|j�|�dSdSdSr)r"�set_event_loopr�rmr�r�r=r<r'rrr��s
�z*_UnixDefaultEventLoopPolicy.set_event_loopcCs	|jdur
|��|jSr)r�r�r�rrrre�s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs 	|jdur|j��||_dSr)r�r,)r%rurrr�set_child_watcher�s


z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�r!Z
_loop_factoryr#r�r�rer�r�rrr'rr��s
r�)2rJr�rzrr�rAr�r�r/r-rmr1�rrrrrrr	r
rr�logr
�__all__r�ImportErrorrrZBaseSelectorEventLoopr!Z
ReadTransportr[Z_FlowControlMixinZWriteTransportrcZBaseSubprocessTransportrhrrr[rrrrZBaseDefaultEventLoopPolicyr�rrrrrr�<module>sd
	
		�NON5Ji}Y2