Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/asyncio/__pycache__/unix_events.cpython-39.opt-2.pyc

a

���e*��@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�ZGdd�dej�ZGdd�dej�Z Gdd�dej!ej"�Z#Gdd�dej$�Z%Gdd�d�Z&Gdd�de&�Z'dd �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�DefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS�N�)�signum�framerr�8/opt/alt/python39/lib64/python3.9/asyncio/unix_events.py�_sighandler_noop*srcs�eZdZd(�fdd�	Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	d)dd�Z
d*dd�Zd+dd�Zdd�Z
d,ddddd�dd�Zd-dddddd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z�ZS).�_UnixSelectorEventLoopNcst��|�i|_dSr)�super�__init__�_signal_handlers)�self�selector��	__class__rrr5sz_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}ztt
|���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�r6td|�d���n�WYd}~n
d}~00dS)Nz3coroutines cannot be used with add_signal_handler()F����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
|�|�dSr)r�getZ
_cancelledr*Z_add_callback_signalsafe)r r0rHrrrr1{sz%_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�Wn4ttfy�}zt
�d|�WYd}~n
d}~00dS)NFr6r7r4r5T)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)Nzsig must be an int, not zinvalid signal number )�
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
|r|dur6td��n |dur&td��|dur6td��|dur�|durNtd��t�|�}t�tjtjd�}z |�d�|�||�IdHWq�|���Yq�0n@|dur�td��|j	tjks�|j
tjkr�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)r=�os�fspath�socket�AF_UNIX�SOCK_STREAM�setblockingZsock_connectr&�family�typeZ_create_connection_transport)	r �protocol_factory�pathrqrrrsrt�	transportrVrrr�create_unix_connection�sL���



��
�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�|��t�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)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__rr&r3rIr1r*r9rYr[rmrar�r�r�r�r�r��
__classcell__rrr"rr/s@-
 �
�
�
��.��CFrcs�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
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 �looprUrVrWrX�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�Zeof_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�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�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
Cs.t|t�rt|�}|sdS|js&|jrN|jtjkr<t�d�|jd7_dS|j	�szt
�|j|�}Wnnt
tfy�d}YnVttfy��Yn@ty�}z(|jd7_|�|d�WYd}~dSd}~00|t|�kr�dS|dk�rt|�|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)rPr��
memoryviewr�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�s6


z_UnixWritePipeTransport.writec
Cs�zt�|j|j�}Wn�ttfy*Yn�ttfy@�Yn�ty�}z>|j�	�|j
d7_
|j�|j�|�
|d�WYd}~nnd}~00|t|j�kr�|j�	�|j�|j�|��|jr�|j�|j�|�d�dS|dkr�|jd|�=dS)Nrrr)rxrr�r�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_eofcCs8|jr
dSd|_|js4|j�|j�|j�|jd�dSr�)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�rr�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�rrrrr�r�r�r&r+r,r�r	r�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@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rcGs
t��dSr��NotImplementedError�r rorErFrrrr`9s	z&AbstractChildWatcher.add_child_handlercCs
t��dSrr�r rorrr�remove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs
t��dSrr�r r�rrr�attach_loopLsz AbstractChildWatcher.attach_loopcCs
t��dSrrr�rrrr&VszAbstractChildWatcher.closecCs
t��dSrrr�rrrr]]szAbstractChildWatcher.is_activecCs
t��dSrrr�rrr�	__enter__fszAbstractChildWatcher.__enter__cCs
t��dSrr�r �a�b�crrr�__exit__lszAbstractChildWatcher.__exit__N)
r�r�r�r`rrr&r]rrrrrrr"s
	rc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)rcCsd|_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 rJrxZ
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 r-rKr�r�rxr&)r ror)r*rrrr�s
z&PidfdChildWatcher.remove_child_handlerN)r�r�r�rrrr]r&rr`r+rrrrrrqs	rcCs2t�|�rt�|�St�|�r*t�|�S|SdSr)rx�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS)r1rrrr0�s



r0c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseChildWatchercCsd|_i|_dSrrr�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_allcCsf|jdur$|dur$|jr$t�dt�|jdur<|j�tj�||_|durb|�tj|j	�|�
�dSr&)r�r r+r,r'r*r:�SIGCHLDrI�	_sig_chldr9rrrrr�s�
zBaseChildWatcher.attach_loopc
Cs^z|��WnLttfy$�Yn6tyX}z|j�d|d��WYd}~n
d}~00dS)N�$Unknown exception in SIGCHLD handler)r�r�)r9rbrcrdr�r�r�rrrr;�s�zBaseChildWatcher._sig_chldN)
r�r�r�rr&r]r8r9rr;rrrrr6�sr6csLeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs|j��t���dSr)r r.rr&r�r"rrr&
s
zSafeChildWatcher.closecCs|Srrr�rrrrszSafeChildWatcher.__enter__cCsdSrrrrrrrszSafeChildWatcher.__exit__cGs||f|j|<|�|�dSr)r r8rrrrr`sz"SafeChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dS�NTF�r rKrrrrrs
z%SafeChildWatcher.remove_child_handlercCst|j�D]}|�|�q
dSr�r)r r8rrrrr9$sz SafeChildWatcher._do_waitpid_allcCs�zt�|tj�\}}Wn&ty<|}d}t�d|�Yn.0|dkrJdSt|�}|j��rjt�	d||�z|j
�|�\}}Wn,ty�|j��r�tjd|dd�Yn0|||g|�R�dS)Nr,�8Unknown child process pid %d, will report returncode 255r�$process %s exited with returncode %s�'Child watcher got an unexpected pid: %rTr�)
rxr.�WNOHANGr/r
rr0r�r�r�r r-rK)r r7ror1rprErFrrrr8)s0�

�
�zSafeChildWatcher._do_waitpid)r�r�r�r&rrr`rr9r8r�rrr"rrsrcsPeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rcs$t���t��|_i|_d|_dSr�)rr�	threadingZLock�_lock�_zombies�_forksr�r"rrrVs

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

zFastChildWatcher.closecCs<|j�"|jd7_|Wd�S1s.0YdS)Nr)rErGr�rrrraszFastChildWatcher.__enter__cCst|j�N|jd8_|js"|js2Wd�dSt|j�}|j��Wd�n1sZ0Yt�d|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)rErGrFr@r.r
r)r rrrZcollateral_victimsrrrrgs
(�zFastChildWatcher.__exit__c	Gs||j�Pz|j�|�}Wn.tyF||f|j|<YWd�dS0Wd�n1s\0Y|||g|�R�dSr)rErFr-rKr )r rorErFrprrrr`us2z"FastChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSr=r>rrrrr�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 %srAz8Caught subprocess termination from unknown pid: %d -> %d)rxr.rCr/r0rEr r-rKrGrFr�r�r
r�r)r ror1rprErFrrrr9�s:

�

�"�z FastChildWatcher._do_waitpid_all)r�r�r�rr&rrr`rr9r�rrr"rrLs
rc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rcCsi|_d|_dSr)r �_saved_sighandlerr�rrrr�szMultiLoopChildWatcher.__init__cCs
|jduSr)rHr�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.rHr:�	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 r8)r rorErFr�rrrr`�sz'MultiLoopChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSr=r>rrrrr�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)rHr:r:r;r
rrNrArrrrr�s


z!MultiLoopChildWatcher.attach_loopcCst|j�D]}|�|�q
dSrr?rrrrr9sz%MultiLoopChildWatcher._do_waitpid_allc	Cs�zt�|tj�\}}Wn*ty@|}d}t�d|�d}Yn0|dkrNdSt|�}d}z|j�|�\}}}Wn"t	y�tjd|dd�YnJ0|�
�r�t�d||�n0|r�|��r�t�d	||�|j
|||g|�R�dS)
Nr,r@FrTrBr��%Loop %r that handles pid %r is closedrA)rxr.rCr/r
rr0r r-rK�	is_closedr�r�rn)	r r7ror1rpZ	debug_logr�rErFrrrr8s6�
��z!MultiLoopChildWatcher._do_waitpidc	CsHz|��Wn6ttfy$�Yn tyBtjddd�Yn0dS)Nr<Tr�)r9rbrcrdr
r)r rrrrrr;)szMultiLoopChildWatcher._sig_chldN)r�r�r�rr]r&rrr`rrr9r8r;rrrrr�s%rc@sjeZdZdd�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?szThreadedChildWatcher.__init__cCsdSr�rr�rrrr]CszThreadedChildWatcher.is_activecCs|��dSr)�
_join_threadsr�rrrr&FszThreadedChildWatcher.closecCs.dd�t|j���D�}|D]}|��qdS)NcSsg|]}|��r|js|�qSr)�is_alive�daemon��.0�threadrrr�
<listcomp>Ks�z6ThreadedChildWatcher._join_threads.<locals>.<listcomp>)r)rPr(r�)r �threadsrVrrrrQIsz"ThreadedChildWatcher._join_threadscCs|Srrr�rrrrPszThreadedChildWatcher.__enter__cCsdSrrrJrrrrSszThreadedChildWatcher.__exit__cCs6dd�t|j���D�}|r2||j�d�t|d�dS)NcSsg|]}|��r|�qSr)rRrTrrrrWWs�z0ThreadedChildWatcher.__del__.<locals>.<listcomp>z0 has registered but not finished child processesr$)r)rPr(r#r-)r r�rXrrrr�Vs�zThreadedChildWatcher.__del__cGsFt��}tj|jdt|j���||||fdd�}||j|<|��dS)Nzwaitpid-T)�target�namerFrS)	rrKrDZThreadr8�nextrOrP�start)r rorErFr�rVrrrr`^s
�
z&ThreadedChildWatcher.add_child_handlercCsdSr�rrrrrrgsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrmsz ThreadedChildWatcher.attach_loopcCs�zt�|d�\}}Wn&ty:|}d}t�d|�Yn 0t|�}|��rZt�d||�|��rrt�d||�n|j	|||g|�R�|j
�|�dS)Nrr,r@rArL)rxr.r/r
rr0r�r�rMrnrPr-)r r�r7rErFror1rprrrr8ps$�
�z ThreadedChildWatcher._do_waitpidN)r�r�r�rr]r&rQrrr+r,r�r`rrr8rrrrr2s
	rcsDeZdZeZ�fdd�Zdd�Z�fdd�Zdd�Zd	d
�Z	�Z
S)�_UnixDefaultEventLoopPolicycst���d|_dSr)rr�_watcherr�r"rrr�s
z$_UnixDefaultEventLoopPolicy.__init__cCs\tj�B|jdur:t�|_t��t��ur:|j�|jj	�Wd�n1sN0YdSr)
rrEr^rrD�current_thread�main_threadr�_localr�r�rrr�
_init_watcher�s

z)_UnixDefaultEventLoopPolicy._init_watchercs6t��|�|jdur2t��t��ur2|j�|�dSr)r�set_event_loopr^rDr_r`rrr"rrrc�s

�z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdur|��|jSr)r^rbr�rrrr\�s
z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdur|j��||_dSr)r^r&)r rkrrr�set_child_watcher�s

z-_UnixDefaultEventLoopPolicy.set_child_watcher)r�r�r�rZ
_loop_factoryrrbrcr\rdr�rrr"rr]�s
r])2rCr�rNrxr�r:rzr�rr'rDr+�rrrrrrr	r
rr�logr
�__all__r��ImportErrorrZBaseSelectorEventLooprZ
ReadTransportrSZ_FlowControlMixinZWriteTransportrZZBaseSubprocessTransportr_rrr0r6rrrrZBaseDefaultEventLoopPolicyr]rrrrrr�<module>s`	
	�NON5Ji}Y2

Hacked By AnonymousFox1.0, Coded By AnonymousFox