AlkantarClanX12

Your IP : 18.119.107.159


Current Path : /opt/alt/python310/lib64/python3.10/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/asyncio/__pycache__/proactor_events.cpython-310.opt-1.pyc

o

6��f�@sXdZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
dd	l	mZdd
l	mZddl	mZddl	mZdd
lmZdd�ZGdd�dejej�ZGdd�deej�ZGdd�deej�ZGdd�de�ZGdd�deej�ZGdd�deeej�Z Gdd�deeej�Z!Gdd�de
j"�Z#dS) z�Event loop using a proactor and related classes.

A proactor is a "notify-on-completion" multiplexer.  Currently a
proactor is only implemented on Windows with IOCP.
)�BaseProactorEventLoop�N�)�base_events)�	constants)�futures)�
exceptions)�	protocols)�sslproto)�
transports)�trsock)�loggercCs�t�|�|jd<z	|��|jd<Wntjy(|j��r&tj	d|dd�Ynwd|jvrIz
|�
�|jd<WdStjyHd|jd<YdSwdS)N�socketZsocknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extraZgetsocknamer
�error�_loop�	get_debugr�warningZgetpeername)�	transport�sock�r�>/opt/alt/python310/lib64/python3.10/asyncio/proactor_events.py�_set_socket_extras"
���
��rcs�eZdZdZ		d�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejfdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t��||�|�|�||_|�|�||_d|_d|_d|_d|_	d|_
d|_d|_d|_
|jdur9|j��|j�|jj|�|durQ|j�tj|d�dSdS)NrF)�super�__init__�
_set_extra�_sock�set_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_called_connection_lost�_eof_writtenZ_attachr�	call_soon�	_protocolZconnection_maderZ_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server��	__class__rrr2s*




��z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdur|�d�n|jr|�d�|jdur(|�d|j�����|jdur6|�d|j���|jdurD|�d|j���|jrR|�dt	|j����|j
rZ|�d�d�d	�|��S)
N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� )
r5�__name__r �appendr(�filenor$r%r#�lenr*�format�join)r.�inforrr�__repr__Is 






z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)r�r.rrrrr[�z%_ProactorBasePipeTransport._set_extracCs
||_dS�N�r,)r.r0rrrr!^�
z'_ProactorBasePipeTransport.set_protocolcC�|jSrDrE�r.rrr�get_protocola�z'_ProactorBasePipeTransport.get_protocolcCrGrD)r(rHrrr�
is_closingdrJz%_ProactorBasePipeTransport.is_closingcCs`|jrdSd|_|jd7_|js|jdur|j�|jd�|jdur.|j��d|_dSdS)NTr)	r(r'r#r%rr+�_call_connection_lostr$�cancelrHrrr�closegs


�z _ProactorBasePipeTransport.closecCs0|jdur|d|��t|d�|j��dSdS)Nzunclosed transport )�source)r �ResourceWarningrN)r.Z_warnrrr�__del__rs
�z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportc	Csnz0t|t�r|j��rtjd||dd�n|j�||||jd��W|�|�dSW|�|�dS|�|�w)Nz%r: %sTr)�message�	exceptionrr0)	�
isinstance�OSErrorrrr�debug�call_exception_handlerr,�_force_close)r.�excrSrrr�_fatal_errorws

�
��z'_ProactorBasePipeTransport._fatal_errorcCs�|jdur|j��s|dur|j�d�n|j�|�|jr#|jr#dSd|_|jd7_|jr8|j��d|_|j	rC|j	��d|_	d|_
d|_|j�
|j|�dS)NTrr)�
_empty_waiter�done�
set_resultZ
set_exceptionr(r)r'r%rMr$r&r#rr+rL)r.rZrrrrY�s"

z'_ProactorBasePipeTransport._force_closec	Cs�|jrdSz6|j�|�Wt|jd�r!|j��dkr!|j�tj�|j�	�d|_|j
}|dur7|��d|_
d|_dSt|jd�rP|j��dkrP|j�tj�|j�	�d|_|j
}|durf|��d|_
d|_w)N�shutdown���T)r)r,Zconnection_lost�hasattrr r;r_r
Z	SHUT_RDWRrNr"Z_detach)r.rZr3rrrrL�s,

�
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdur|t|j�7}|SrD)r&r#r<)r.�sizerrr�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size�NNN)rR)r9�
__module__�__qualname__�__doc__rr@rr!rIrKrN�warnings�warnrQr[rYrLrc�
__classcell__rrr4rr.s �
rcsXeZdZdZ		d�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
�ZS)�_ProactorReadPipeTransportzTransport for read pipes.N�csDd|_d|_t��||||||�t|�|_|j�|j�d|_dS)Nr`TF)	�_pending_data_length�_pausedrr�	bytearray�_datarr+�
_loop_reading)r.r/rr0r1r2r3Zbuffer_sizer4rrr�s

z#_ProactorReadPipeTransport.__init__cCs|jo|jSrD)rnr(rHrrr�
is_reading�sz%_ProactorReadPipeTransport.is_readingcCs4|js|jrdSd|_|j��rt�d|�dSdS)NTz%r pauses reading)r(rnrrrrWrHrrr�
pause_reading�s

�z(_ProactorReadPipeTransport.pause_readingcCs~|js|jsdSd|_|jdur|j�|jd�|j}d|_|dkr0|j�|j|jd|�|�|j�	�r=t
�d|�dSdS)NFr`z%r resumes reading)r(rnr$rr+rqrm�_data_receivedrprrrW)r.�lengthrrr�resume_reading�s

�z)_ProactorReadPipeTransport.resume_readingc
Cs~|j��rt�d|�z|j��}Wn"ttfy�ty4}z
|�	|d�WYd}~dSd}~ww|s=|�
�dSdS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrrrWr,Zeof_received�
SystemExit�KeyboardInterrupt�
BaseExceptionr[rN)r.Z	keep_openrZrrr�
_eof_received�s 
����z(_ProactorReadPipeTransport._eof_receivedc
Cs�|jr||_dS|dkr|��dSt|jtj�rFz
t�|j|�WdStt	fy-�t
yE}z
|�|d�WYd}~dSd}~ww|j�|�dS)Nrz3Fatal error: protocol.buffer_updated() call failed.)
rnrmrzrUr,rZBufferedProtocolZ_feed_data_to_buffered_protorwrxryr[Z
data_received)r.�datarurZrrrrt�s&���z)_ProactorReadPipeTransport._data_receivedc
Cs�d}d}z�zR|dur5d|_|��r1|��}|dkr)WW|dkr'|�||�dSdS|jd|�}n|��|jrHWW|dkrF|�||�dSdS|jsV|jj	�
|j|j�|_Wnbty}z|jsi|�
|d�n|j��rutjddd�WYd}~nId}~wty�}z|�|�WYd}~n3d}~wty�}z|�
|d�WYd}~nd}~wtjy�|js��Ynw|js�|j�|j�W|dkr�|�||�dSdS|dkr�|�||�ww)Nr`rz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r$r]�resultrtrprMr(rnr�	_proactor�	recv_intor �ConnectionAbortedErrorr[rrrW�ConnectionResetErrorrYrVr�CancelledError�add_done_callbackrq)r.�futrur{rZrrrrqsb"�����
���������z(_ProactorReadPipeTransport._loop_reading)NNNrlrD)r9rerfrgrrrrsrvrzrtrqrjrrr4rrk�s�
rkcs^eZdZdZdZ�fdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�_ProactorBaseWritePipeTransportzTransport for write pipes.Tcst�j|i|��d|_dSrD)rrr\�r.�args�kwr4rrrMs
z(_ProactorBaseWritePipeTransport.__init__cCs�t|tttf�stdt|�j����|jrtd��|j	dur"td��|s&dS|j
r=|j
tjkr4t
�d�|j
d7_
dS|jdurL|jt|�d�dS|jsZt|�|_|��dS|j�|�|��dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r{)rU�bytesro�
memoryview�	TypeError�typer9r*�RuntimeErrorr\r'r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESrrr%�
_loop_writingr#�_maybe_pause_protocol�extend)r.r{rrr�writeQs0��



z%_ProactorBaseWritePipeTransport.writeNc
Csdz�|dur|jdur|jrWdSd|_d|_|r|��|dur&|j}d|_|sB|jr3|j�|jd�|jr=|j	�
tj�|�
�n'|jj�|j	|�|_|j��sbt|�|_|j�|j�|��n|j�|j�|jdur||jdur|j�d�WdSWdSWdSty�}z|�|�WYd}~dSd}~wty�}z
|�|d�WYd}~dSd}~ww)Nrz#Fatal write error on pipe transport)r%r(r&r|r#rr+rLr*r r_r
�SHUT_WR�_maybe_resume_protocolr}�sendr]r<r�r�r�r\r^r�rYrVr[)r.�fr{rZrrrr�ws@



����z-_ProactorBaseWritePipeTransport._loop_writingcC�dS�NTrrHrrr�
can_write_eof��z-_ProactorBaseWritePipeTransport.can_write_eofcCs|��dSrD)rNrHrrr�	write_eof�sz)_ProactorBaseWritePipeTransport.write_eofcC�|�d�dSrD�rYrHrrr�abort�rCz%_ProactorBaseWritePipeTransport.abortcCs:|jdur	td��|j��|_|jdur|j�d�|jS)NzEmpty waiter is already set)r\r�rZ
create_futurer%r^rHrrr�_make_empty_waiter�s

z2_ProactorBaseWritePipeTransport._make_empty_waitercCs
d|_dSrD)r\rHrrr�_reset_empty_waiter�rFz3_ProactorBaseWritePipeTransport._reset_empty_waiter�NN)r9rerfrgZ_start_tls_compatiblerr�r�r�r�r�r�r�rjrrr4rr�Gs
&)r�cs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs8t�j|i|��|jj�|jd�|_|j�|j�dS)N�)	rrrr}�recvr r$r��_pipe_closedr�r4rrr�sz$_ProactorWritePipeTransport.__init__cCsB|��rdS|jrdSd|_|jdur|�t��dS|��dSrD)Z	cancelledr(r$r%rY�BrokenPipeErrorrN)r.r�rrrr��s
z(_ProactorWritePipeTransport._pipe_closed)r9rerfrr�rjrrr4rr��sr�cs\eZdZdZ		d�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	ddd�Z
�ZS)�_ProactorDatagramTransportiNcs>||_d|_t�j|||||d�t��|_|j�|j	�dS)N)r1r2)
�_addressr\rr�collections�dequer#rr+rq)r.r/rr0�addressr1r2r4rrr�s

z#_ProactorDatagramTransport.__init__cC�t||�dSrD�rrBrrrr�rCz%_ProactorDatagramTransport._set_extracCstdd�|jD��S)Ncss�|]	\}}t|�VqdSrD)r<)�.0r{�_rrr�	<genexpr>�s�zC_ProactorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr#rHrrrrc�sz0_ProactorDatagramTransport.get_write_buffer_sizecCr�rDr�rHrrrr��rCz _ProactorDatagramTransport.abortcCs�t|tttf�stdt|���|sdS|jdur'|d|jfvr'td|j����|jrA|jrA|jt	j
kr8t�d�|jd7_dS|j
�t|�|f�|jdurT|��|��dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rUr�ror�r�r�r��
ValueErrorr'rr�rrr#r:r%r�r�)r.r{�addrrrr�sendto�s&�
�

z!_ProactorDatagramTransport.sendtoc
CszK|jrWdSd|_|r|��|jr|jr'|jr'|jr$|j�|jd�WdS|j�	�\}}|jdur>|jj
�|j|�|_n|jj
j
|j||d�|_Wn1tyd}z
|j�|�WYd}~dSd}~wty|}z
|�|d�WYd}~dSd}~ww|j�|j�|��dS)N)r�z'Fatal write error on datagram transport)r'r%r|r#r�r(rr+rL�popleftr}r�r r�rVr,�error_received�	Exceptionr[r�r�r�)r.r�r{r�rZrrrr��s:
������z(_ProactorDatagramTransport._loop_writingc
Cs~d}z�zq|jrWW|r|j�||�dSdSd|_|durE|��}|jr5d}WW|r3|j�||�dSdS|jdurA||j}}n|\}}|jrWWW|rU|j�||�dSdS|jdurh|jj�	|j
|j�|_n|jj�|j
|j�|_Wn%t
y�}z|j�|�WYd}~nd}~wtjy�|js��Yn
w|jdur�|j�|j�W|r�|j�||�dSdS|r�|j�||�wwrD)r'r,Zdatagram_receivedr$r|r(r�rr}r�r �max_sizeZrecvfromrVr�rr�r�rq)r.r�r{r��resrZrrrrq s`$���
��
�������
���z(_ProactorDatagramTransport._loop_readingrdrD)r9rerfr�rrrcr�r�r�rqrjrrr4rr��s�

!r�c@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCr�)NFrrHrrrr�Qr�z*_ProactorDuplexPipeTransport.can_write_eofcCst�rD)�NotImplementedErrorrHrrrr�Tr�z&_ProactorDuplexPipeTransport.write_eofN)r9rerfrgr�r�rrrrr�Lsr�csFeZdZdZejjZ		d�fdd�	Zdd�Z	dd�Z
d	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t��||||||�t�|�dSrD)rrrZ_set_nodelayr-r4rrr_sz!_ProactorSocketTransport.__init__cCr�rDr�rBrrrrdrCz#_ProactorSocketTransport._set_extracCr�r�rrHrrrr�gr�z&_ProactorSocketTransport.can_write_eofcCs6|js|jrdSd|_|jdur|j�tj�dSdSr�)r(r*r%r r_r
r�rHrrrr�js
�z"_ProactorSocketTransport.write_eofrd)
r9rerfrgrZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerrr�r�rjrrr4rr�Xs�r�cseZdZ�fdd�Z		d3dd�Z	d4dddddd�dd	�Z	d3d
d�Z		d5dd
�Z		d5dd�Z		d5dd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd4d&d'�Zd(d)�Z	*	d6d+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS)7rcslt���t�d|jj�||_||_d|_i|_	|�
|�|��t�
�t��ur4t�|j���dSdS)NzUsing proactor: %s)rrrrWr5r9r}�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe�	threading�current_thread�main_thread�signal�
set_wakeup_fd�_csockr;)r.Zproactorr4rrrts

�zBaseProactorEventLoop.__init__NcC�t||||||�SrD)r�)r.rr0r1r2r3rrr�_make_socket_transport��
�z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer2r3�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r��r2r3)r	ZSSLProtocolr�Z_app_transport)r.Zrawsockr0�
sslcontextr1r�r�r2r3r�Zssl_protocolrrr�_make_ssl_transport�s��z)BaseProactorEventLoop._make_ssl_transportcCr�rD)r�)r.rr0r�r1r2rrr�_make_datagram_transport�r�z.BaseProactorEventLoop._make_datagram_transportcC�t|||||�SrD)r��r.rr0r1r2rrr�_make_duplex_pipe_transport�s�z1BaseProactorEventLoop._make_duplex_pipe_transportcCr�rD)rkr�rrr�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCr�rD)r�r�rrr�_make_write_pipe_transport�s�z0BaseProactorEventLoop._make_write_pipe_transportcsj|��rtd��|��rdSt��t��urt�d�|��|�	�|j
��d|_
d|_t
���dS)Nz!Cannot close a running event loopr`)Z
is_runningr��	is_closedr�r�r�r�r��_stop_accept_futures�_close_self_piper}rNr�rrHr4rrrN�s

zBaseProactorEventLoop.closec���|j�||�IdHSrD)r}r�)r.r�nrrr�	sock_recv���zBaseProactorEventLoop.sock_recvc�r�rD)r}r~)r.rZbufrrr�sock_recv_into�r�z$BaseProactorEventLoop.sock_recv_intoc�r�rD)r}r�)r.rr{rrr�sock_sendall�r�z"BaseProactorEventLoop.sock_sendallc�r�rD)r}Zconnect)r.rr�rrr�sock_connect�r�z"BaseProactorEventLoop.sock_connectc�s�|j�|�IdHSrD)r}�acceptrBrrr�sock_accept�s�z!BaseProactorEventLoop.sock_acceptc
�s�z|��}Wnttjfy}zt�d��d}~wwzt�|�j}Wnt	y0t�d��w|r5|n|}|s;dSt
|d�}|rIt
|||�n|}	t
||�}d}
z.	t
|	||�}|dkrl|
W|
dkrk|�|�SS|j�
||||�IdH||7}|
|7}
qT|
dkr�|�|�ww)Nznot a regular filerl��)r;�AttributeError�io�UnsupportedOperationrZSendfileNotAvailableError�os�fstat�st_sizerV�min�seekr}�sendfile)r.r�file�offset�countr;�errZfsizeZ	blocksizeZend_posZ
total_sentrrr�_sock_sendfile_native�sD�
��
�

����z+BaseProactorEventLoop._sock_sendfile_nativec�sn�|��}|��|��IdHz|j|j|||dd�IdHW|��|r*|��SS|��|r6|��ww)NF)Zfallback)rrrsr�Z
sock_sendfiler r�rv)r.Ztranspr�r�r�rvrrr�_sendfile_native�s ��
��
�z&BaseProactorEventLoop._sendfile_nativecCsL|jdur
|j��d|_|j��d|_|j��d|_|jd8_dS)Nr)r�rM�_ssockrNr��
_internal_fdsrHrrrr��s



z&BaseProactorEventLoop._close_self_pipecCs:t��\|_|_|j�d�|j�d�|jd7_dS)NFr)r
Z
socketpairr�r�Zsetblockingr�rHrrrr��sz%BaseProactorEventLoop._make_self_pipec
Cs�z|dur	|��|j|urWdS|j�|jd�}Wn/tjy%YdSttfy.�t	yI}z|�
d||d��WYd}~dSd}~ww||_|�|j�dS)Niz.Error on reading from the event loop self pipe)rSrTr/)
r|r�r}r�r�rr�rwrxryrXr��_loop_self_reading)r.r�rZrrrr�s(
���z(BaseProactorEventLoop._loop_self_readingcCsR|j}|dur	dSz|�d�WdSty(|jr%tjddd�YdSYdSw)N�z3Fail to write a null byte into the self-pipe socketTr)r�r�rV�_debugrrW)r.Zcsockrrr�_write_to_self s���z$BaseProactorEventLoop._write_to_self�dcs(d�������fdd�	�����dS)Nc
sJzE|dur7|��\}}�jrt�d�||���}�dur,�j||�dd|i��d�n�j||d|i�d����r>WdS�j���}WnQt	y�}z7��
�dkrd��d|t�
��d�����n�jrvtjd	�dd
�WYd}~dSWYd}~dSWYd}~dSd}~wtjy����YdSw|�j��
�<|���dS)Nz#%r got a new connection from %r: %rTr)r�r2r3r�r�r`zAccept failed on a socket)rSrTr
zAccept failed on socket %rr)r|r�rrWr�r�r�r}r�rVr;rXrrrNrr�r�r�)r�Zconnr�r0rZ�r/�protocol_factoryr.r3rr�r�rrr/6sR����
�����z2BaseProactorEventLoop._start_serving.<locals>.looprD)r+)r.r�rr�r3Zbacklogr�rr�r�_start_serving2s%z$BaseProactorEventLoop._start_servingcCsdSrDr)r.Z
event_listrrr�_process_events]sz%BaseProactorEventLoop._process_eventscCs&|j��D]}|��q|j��dSrD)r��valuesrM�clear)r.�futurerrrr�as
z*BaseProactorEventLoop._stop_accept_futurescCs6|j�|��d�}|r|��|j�|�|��dSrD)r��popr;rMr}�
_stop_servingrN)r.rr�rrrr�fs
z#BaseProactorEventLoop._stop_servingrdrDr�)NNr�N)r9rerfrr�r�r�r�r�r�rNr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rjrrr4rrrsP

���
�
�
�
�


�+r)$rg�__all__r�r�r
rhr�r�r��rrrrrr	r
r�logrrZ_FlowControlMixinZ
BaseTransportrZ
ReadTransportrkZWriteTransportr�r�ZDatagramTransportr�Z	Transportr�r�Z
BaseEventLooprrrrr�<module>sX���n���