AlkantarClanX12

Your IP : 18.116.15.22


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

a

R�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<Wn.tjyP|j��rLtj	d|dd�Yn0d|jvr�z|�
�|jd<Wntjy�d|jd<Yn0dS)N�socketZsocknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extraZgetsocknamer
�error�_loop�	get_debugr�warningZgetpeername)�	transport�sock�r�</opt/alt/python39/lib64/python3.9/asyncio/proactor_events.py�_set_socket_extras
�
rcs�eZdZdZd�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|_|jdurl|j�
�|j�|jj|�|dur�|j�tj|d�dS)NrF)�super�__init__�
_set_extra�_sock�set_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_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|jr0|�d�|jdurP|�d|j�����|jdurl|�d|j���|jdur�|�d|j���|jr�|�dt	|j����|j
r�|�d�d�d	�|��S)
N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� )
r4�__name__r �appendr(�filenor$r%r#�lenr)�format�join)r-�inforrr�__repr__Hs 






z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)r�r-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs
||_dS�N�r+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrC�r-rrr�get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr�
is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr
dSd|_|jd7_|js>|jdur>|j�|jd�|jdurX|j��d|_dS)NTr)	r(r'r#r%rr*�_call_connection_lostr$�cancelrDrrr�closefs

z _ProactorBasePipeTransport.closecCs*|jdur&|d|��t|d�|��dS)Nzunclosed transport )�source)r �ResourceWarningrI)r-Z_warnrrr�__del__qs
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportc	Cs`zNt|t�r*|j��rBtjd||dd�n|j�||||jd��W|�|�n|�|�0dS)Nz%r: %sTr)�message�	exceptionrr/)	�
isinstance�OSErrorrrr�debug�call_exception_handlerr+�_force_close)r-�excrNrrr�_fatal_errorvs

�
z'_ProactorBasePipeTransport._fatal_errorcCs�|jdur6|j��s6|dur*|j�d�n|j�|�|jr@dSd|_|jd7_|jrj|j��d|_|jr�|j��d|_d|_	d|_
|j�|j
|�dS)NTrr)�
_empty_waiter�done�
set_resultZ
set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrT�s"

z'_ProactorBasePipeTransport._force_closec	Cs�zd|j�|�Wt|jd�r8|j��dkr8|j�tj�|j��d|_|j	}|dur�|�
�d|_	nVt|jd�r�|j��dkr�|j�tj�|j��d|_|j	}|dur�|�
�d|_	0dS)N�shutdown���)r+Zconnection_lost�hasattrr r:rZr
Z	SHUT_RDWRrIr"Z_detach)r-rUr2rrrrG�s$
�
z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdur|t|j�7}|SrB)r&r#r;)r-�sizerrr�get_write_buffer_size�s
z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8�
__module__�__qualname__�__doc__rr?rr!rErFrI�warnings�warnrLrVrTrGr^�
__classcell__rrr3rr.s�
rcsTeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
�ZS)�_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t��||||||�|j�|j�d|_dS)NTF)�
_pending_data�_pausedrrrr*�
_loop_readingr,r3rrr�s
z#_ProactorReadPipeTransport.__init__cCs|jo|jSrB)rgr(rDrrr�
is_reading�sz%_ProactorReadPipeTransport.is_readingcCs0|js|jrdSd|_|j��r,t�d|�dS)NTz%r pauses reading)r(rgrrrrRrDrrr�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsn|js|jsdSd|_|jdur0|j�|jd�|j}d|_|durT|j�|j|�|j��rjt	�
d|�dS)NFz%r resumes reading)r(rgr$rr*rhrf�_data_receivedrrrR�r-�datarrr�resume_reading�s

z)_ProactorReadPipeTransport.resume_readingc
Cs~|j��rt�d|�z|j��}WnHttfy<�Yn2tyl}z|�	|d�WYd}~dSd}~00|sz|�
�dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrrrRr+Zeof_received�
SystemExit�KeyboardInterrupt�
BaseExceptionrVrI)r-Z	keep_openrUrrr�
_eof_received�s
�z(_ProactorReadPipeTransport._eof_receivedc
Cs�|jr|jdusJ�||_dS|s.|��dSt|jtj�r�zt�|j|�Wq�tt	fyf�Yq�t
y�}z|�|d�WYd}~dSd}~00n|j�|�dS)Nz3Fatal error: protocol.buffer_updated() call failed.)
rgrfrrrPr+rZBufferedProtocolZ_feed_data_to_buffered_protororprqrVZ
data_received)r-rmrUrrrrk�s$�z)_ProactorReadPipeTransport._data_receivedc
Cs�d}�z�z�|durP|j|us0|jdur,|js0J�d|_|��rH|��}n|��|jrtd}WW|durp|�|�dS|dkr�WW|dur�|�|�dS|js�|jj�	|j
d�|_Wn�t�y}z8|js�|�|d�n|j�
�r�tjddd�WYd}~n�d}~0t�y2}z|�|�WYd}~nnd}~0t�yb}z|�|d�WYd}~n>d}~0tj�y�|j�s|�Yn0|j�s�|j�|j�W|du�r�|�|�n|du�r�|�|�0dS)N�i�z"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r$r(rX�resultrHrkrgr�	_proactor�recvr �ConnectionAbortedErrorrVrrrR�ConnectionResetErrorrTrQr�CancelledError�add_done_callbackrh)r-�futrmrUrrrrhsV�

�
�
� 
�
z(_ProactorReadPipeTransport._loop_reading)NNN)N)r8r_r`rarrirjrnrrrkrhrdrrr3rre�s�	recs^eZdZdZdZ�fdd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�_ProactorBaseWritePipeTransportzTransport for write pipes.Tcst�j|i|��d|_dSrB)rrrW�r-�args�kwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCs�t|tttf�s$tdt|�j����|jr2td��|j	durDtd��|sLdS|j
rz|j
tjkrht
�d�|j
d7_
dS|jdur�|jdus�J�|jt|�d�n.|js�t|�|_|��n|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)rm)rP�bytes�	bytearray�
memoryview�	TypeError�typer8r)�RuntimeErrorrWr'r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESrrr%r#�
_loop_writing�_maybe_pause_protocol�extendrlrrr�writeKs2��




z%_ProactorBaseWritePipeTransport.writeNc
Cs|�z|dur"|jdur"|jr"WdS||jus0J�d|_d|_|rH|��|dur\|j}d|_|s�|jrv|j�|jd�|jr�|j	�
tj�|�
�n\|jj�|j	|�|_|j��s�|jdks�J�t|�|_|j�|j�|��n|j�|j�|jdu�r|jdu�r|j�d�Wn`t�yF}z|�|�WYd}~n:d}~0t�yv}z|�|d�WYd}~n
d}~00dS)Nrz#Fatal write error on pipe transport)r%r(r&rtr#rr*rGr)r rZr
�SHUT_WR�_maybe_resume_protocolru�sendrXr;rzr�r�rWrYrxrTrQrV)r-�frmrUrrrr�qs<



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS�NTrrDrrr�
can_write_eof�sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|��dSrB)rIrDrrr�	write_eof�sz)_ProactorBaseWritePipeTransport.write_eofcCs|�d�dSrB�rTrDrrr�abort�sz%_ProactorBaseWritePipeTransport.abortcCs:|jdurtd��|j��|_|jdur4|j�d�|jS)NzEmpty waiter is already set)rWr�rZ
create_futurer%rYrDrrr�_make_empty_waiter�s

z2_ProactorBaseWritePipeTransport._make_empty_waitercCs
d|_dSrB)rWrDrrr�_reset_empty_waiter�sz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r_r`raZ_start_tls_compatiblerr�r�r�r�r�r�r�rdrrr3rr|As&
)r|cs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs8t�j|i|��|jj�|jd�|_|j�|j�dS)N�)	rrrrurvr r$rz�_pipe_closedr}r3rrr�sz$_ProactorWritePipeTransport.__init__cCsv|��rdS|��dksJ�|jr4|jdus0J�dS||jusLJ||jf��d|_|jdurj|�t��n|��dS)Nrs)Z	cancelledrtr(r$r%rT�BrokenPipeErrorrI)r-r{rrrr��s
z(_ProactorWritePipeTransport._pipe_closed)r8r_r`rr�rdrrr3rr��sr�csXeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Z	ddd�Z
�ZS)�_ProactorDatagramTransportiNcs>||_d|_t�j|||||d�t��|_|j�|j	�dS)N)r0r1)
�_addressrWrr�collections�dequer#rr*rh)r-r.rr/�addressr0r1r3rrr�s

z#_ProactorDatagramTransport.__init__cCst||�dSrB�rrArrrr�sz%_ProactorDatagramTransport._set_extracCstdd�|jD��S)Ncss|]\}}t|�VqdSrB)r;)�.0rm�_rrr�	<genexpr>�rszC_ProactorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr#rDrrrr^�sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|�d�dSrBr�rDrrrr��sz _ProactorDatagramTransport.abortcCs�t|tttf�stdt|���|s&dS|jdurN|d|jfvrNtd|j����|jr�|jr�|jt	j
krpt�d�|jd7_dS|j
�t|�|f�|jdur�|��|��dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rPr�r�r�r�r�r��
ValueErrorr'rr�rrr#r9r%r�r�)r-rm�addrrrr�sendto�s&�
�

z!_ProactorDatagramTransport.sendtoc
Cs z�|jrWdS||jusJ�d|_|r.|��|jr@|jr\|jr\|jrV|j�|jd�WdS|j�	�\}}|jdur�|jj
�|j|�|_n|jj
j
|j||d�|_Wn`ty�}z|j�|�WYd}~nPd}~0t�y}z|�|d�WYd}~n d}~00|j�|j�|��dS)N)r�z'Fatal write error on datagram transport)r'r%rtr#r�r(rr*rG�popleftrur�r r�rQr+�error_received�	ExceptionrVrzr�r�)r-r{rmr�rUrrrr��s4
�� "z(_ProactorDatagramTransport._loop_writingc
Cs�d}�zxz�|jr*WW|r&|j�||�dS|j|usH|jdurD|jsHJ�d|_|dur�|��}|jr�d}WW|r~|j�||�dS|jdur�||j}}n|\}}|jr�WW|r�|j�||�dS|jdur�|jj�	|j
|j�|_n|jj�|j
|j�|_WnPt
�y.}z|j�|�WYd}~nBd}~0tj�yL|j�sH�Yn0|jdu�rh|j�|j�W|�r�|j�||�n|�r�|j�||�0dSrB)r'r+Zdatagram_receivedr$r(rtr�rrurvr �max_sizeZrecvfromrQr�rryrzrh)r-r{rmr��resrUrrrrhsZ$���
�
��
 �z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N)r8r_r`r�rrr^r�r�r�rhrdrrr3rr��s�

!r�c@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrr�Ksz*_ProactorDuplexPipeTransport.can_write_eofcCst�dSrB)�NotImplementedErrorrDrrrr�Nsz&_ProactorDuplexPipeTransport.write_eofN)r8r_r`rar�r�rrrrr�Fsr�csBeZdZdZejjZd�fdd�	Zdd�Z	dd�Z
d	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t��||||||�t�|�dSrB)rrrZ_set_nodelayr,r3rrrYsz!_ProactorSocketTransport.__init__cCst||�dSrBr�rArrrr^sz#_ProactorSocketTransport._set_extracCsdSr�rrDrrrr�asz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdur.|j�tj�dSr�)r(r)r%r rZr
r�rDrrrr�ds

z"_ProactorSocketTransport.write_eof)NNN)
r8r_r`rarZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerrr�r�rdrrr3rr�Rs�r�cs�eZdZ�fdd�Zd3dd�Zd4dddddd�dd	�Zd5d
d�Zd6dd
�Zd7dd�Zd8dd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd9d&d'�Zd(d)�Zd:d+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS);rcsht���t�d|jj�||_||_d|_i|_	|�
|�|��t�
�t��urdt�|j���dS)NzUsing proactor: %s)rrrrRr4r8ru�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe�	threading�current_thread�main_thread�signal�
set_wakeup_fd�_csockr:)r-Zproactorr3rrrns

zBaseProactorEventLoop.__init__NcCst||||||�SrB)r�)r-rr/r0r1r2rrr�_make_socket_transport{s
�z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer1r2�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r��r1r2)r	ZSSLProtocolr�Z_app_transport)r-Zrawsockr/�
sslcontextr0r�r�r1r2r�Zssl_protocolrrr�_make_ssl_transport�s��z)BaseProactorEventLoop._make_ssl_transportcCst||||||�SrB)r�)r-rr/r�r0r1rrr�_make_datagram_transport�s
�z.BaseProactorEventLoop._make_datagram_transportcCst|||||�SrB)r��r-rr/r0r1rrr�_make_duplex_pipe_transport�s�z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�SrB)rer�rrr�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�SrB)r�r�rrr�_make_write_pipe_transport�s�z0BaseProactorEventLoop._make_write_pipe_transportcsj|��rtd��|��rdSt��t��ur6t�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_piperurIr�rrDr3rrrI�s

zBaseProactorEventLoop.closec�s|j�||�IdHSrB)rurv)r-r�nrrr�	sock_recv�szBaseProactorEventLoop.sock_recvc�s|j�||�IdHSrB)ruZ	recv_into)r-rZbufrrr�sock_recv_into�sz$BaseProactorEventLoop.sock_recv_intoc�s|j�||�IdHSrB)rur�)r-rrmrrr�sock_sendall�sz"BaseProactorEventLoop.sock_sendallc�s|j�||�IdHSrB)ruZconnect)r-rr�rrr�sock_connect�sz"BaseProactorEventLoop.sock_connectc�s|j�|�IdHSrB)ru�acceptrArrr�sock_accept�sz!BaseProactorEventLoop.sock_acceptc
�s>z|��}Wn4ttjfy@}zt�d��WYd}~n
d}~00zt�|�j}Wnt	ynt�d��Yn0|rx|n|}|s�dSt
|d�}|r�t
|||�n|}	t
||�}d}
zpt
|	||�}|dkr�|
W|
dkr�|�|�S|j�
||||�IdH||7}|
|7}
q�W|
dk�r:|�|�n|
dk�r8|�|�0dS)Nznot a regular filerl��)r:�AttributeError�io�UnsupportedOperationrZSendfileNotAvailableError�os�fstat�st_sizerQ�min�seekru�sendfile)r-r�file�offset�countr:�errZfsizeZ	blocksizeZend_posZ
total_sentrrr�_sock_sendfile_native�s: 


�
�
z+BaseProactorEventLoop._sock_sendfile_nativec�sn|��}|��|��IdHz4|j|j|||dd�IdHW|��|rP|��Sn|��|rh|��0dS)NF)Zfallback)rirjr�Z
sock_sendfiler r�rn)r-Ztranspr�r�r�rnrrr�_sendfile_native�s"���z&BaseProactorEventLoop._sendfile_nativecCsL|jdur|j��d|_|j��d|_|j��d|_|jd8_dS)Nr)r�rH�_ssockrIr��
_internal_fdsrDrrrr��s



z&BaseProactorEventLoop._close_self_pipecCs:t��\|_|_|j�d�|j�d�|jd7_dS)NFr)r
Z
socketpairr�r�Zsetblockingr�rDrrrr��sz%BaseProactorEventLoop._make_self_pipec
Cs�z4|dur|��|j|ur"WdS|j�|jd�}Wn`tjyJYdSttfy`�YnHt	y�}z|�
d||d��WYd}~nd}~00||_|�|j�dS)Niz.Error on reading from the event loop self pipe)rNrOr.)
rtr�rurvr�rryrorprqrSrz�_loop_self_reading)r-r�rUrrrr��s$
�z(BaseProactorEventLoop._loop_self_readingcCsL|j}|durdSz|�d�Wn&tyF|jrBtjddd�Yn0dS)N�z3Fail to write a null byte into the self-pipe socketTr)r�r�rQ�_debugrrR)r-Zcsockrrr�_write_to_selfs�z$BaseProactorEventLoop._write_to_self�dcs(d�������fdd�	�����dS)Nc
s,z�|durn|��\}}�jr,t�d�||���}�durX�j||�dd|i��d�n�j||d|i�d����r|WdS�j���}Wn�t	y�}zP��
�dkrȈ�d|t�
��d�����n�jr�tjd	�dd
�WYd}~n>d}~0tj�y���Yn0|�j��
�<|���dS)Nz#%r got a new connection from %r: %rTr)r�r1r2r�r�r[zAccept failed on a socket)rNrOr
zAccept failed on socket %rr)rtr�rrRr�r�r�rur�rQr:rSrrrIrryr�rz)r�Zconnr�r/rU�r.�protocol_factoryr-r2rr�r�rrr.0sJ����
�z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r*)r-r�rr�r2Zbacklogr�rr�r�_start_serving,s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z
event_listrrr�_process_eventsWsz%BaseProactorEventLoop._process_eventscCs&|j��D]}|��q
|j��dSrB)r��valuesrH�clear)r-�futurerrrr�[s
z*BaseProactorEventLoop._stop_accept_futurescCs6|j�|��d�}|r|��|j�|�|��dSrB)r��popr:rHru�
_stop_servingrI)r-rr�rrrr�`s
z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNr�N)r8r_r`rr�r�r�r�r�r�rIr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rdrrr3rrlsN
�
���
�
�
�


�
+r)$ra�__all__r�r�r
rbr�r�r��rrrrrr	r
r�logrrZ_FlowControlMixinZ
BaseTransportrZ
ReadTransportreZWriteTransportr|r�ZDatagramTransportr�Z	Transportr�r�Z
BaseEventLooprrrrr�<module>sV���n���