Your IP : 18.118.1.100


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.opt-2.pyc

a

R�f�}�@sTdZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZd
d�ZGdd�dejej�ZGdd�deej�ZGdd�deej�ZGdd�de�ZGdd�deej�ZGdd�deeej�ZGdd�deeej�Z Gdd�de	j!�Z"dS))�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~eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jfdd�Zddd�Z
dd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportNcs�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__rr?rr!rErFrI�warnings�warnrLrVrTrGr^�
__classcell__rrr3rr.s�
rcsPeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zddd�Z	�Z
S)�_ProactorReadPipeTransportNcs:d|_d|_t��||||||�|j�|j�d|_dS)NTF)�
_pending_data�_pausedrrrr*�
_loop_readingr,r3rrr�s
z#_ProactorReadPipeTransport.__init__cCs|jo|jSrB)rfr(rDrrr�
is_reading�sz%_ProactorReadPipeTransport.is_readingcCs0|js|jrdSd|_|j��r,t�d|�dS)NTz%r pauses reading)r(rfrrr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(rfr$rr*rgre�_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||_dS|s |��dSt|jtj�r�zt�|j|�Wq�tt	fyX�Yq�t
y�}z|�|d�WYd}~dSd}~00n|j�|�dS)Nz3Fatal error: protocol.buffer_updated() call failed.)
rfrerqrPr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ
data_received)r-rlrUrrrrj�s"�z)_ProactorReadPipeTransport._data_receivedc
Cs�d}�z�z�|dur2d|_|��r*|��}n|��|jrVd}WW|durR|�|�dS|dkrxWW|durt|�|�dS|js�|jj�	|j
d�|_Wn�ty�}z8|js�|�|d�n|j�
�r�tjddd�WYd}~n�d}~0t�y}z|�|�WYd}~nnd}~0t�yB}z|�|d�WYd}~n>d}~0tj�y`|j�s\�Yn0|j�sx|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$rX�resultrHr(rjrfr�	_proactor�recvr �ConnectionAbortedErrorrVrrrR�ConnectionResetErrorrTrQr�CancelledError�add_done_callbackrg)r-�futrlrUrrrrgsP

�
�
� 
�
z(_ProactorReadPipeTransport._loop_reading)NNN)N)r8r_r`rrhrirmrqrjrgrcrrr3rrd�s�	rdcsZeZdZdZ�fdd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Z�ZS)�_ProactorBaseWritePipeTransportTcst�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�|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)rl)rP�bytes�	bytearray�
memoryview�	TypeError�typer8r)�RuntimeErrorrWr'r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESrrr%�
_loop_writingr#�_maybe_pause_protocol�extendrkrrr�writeKs0��




z%_ProactorBaseWritePipeTransport.writeNc
CsZz�|dur |jdur |jr WdSd|_d|_|r8|��|durL|j}d|_|s�|jrf|j�|jd�|jrz|j	�
tj�|�
�nN|jj�|j	|�|_|j��s�t|�|_|j�|j�|��n|j�|j�|jdur�|jdur�|j�d�Wn`t�y$}z|�|�WYd}~n:d}~0t�yT}z|�|d�WYd}~n
d}~00dS)Nrz#Fatal write error on pipe transport)r%r(r&rsr#rr*rGr)r rZr
�SHUT_WR�_maybe_resume_protocolrt�sendrXr;ryr�r�rWrYrwrTrQrV)r-�frlrUrrrr�qs8



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`Z_start_tls_compatiblerr�r�r�r�r�r�r�rcrrr3rr{As&
)r{cs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs8t�j|i|��|jj�|jd�|_|j�|j�dS)N�)	rrrrtrur r$ry�_pipe_closedr|r3rrr�sz$_ProactorWritePipeTransport.__init__cCs@|��rdS|jrdSd|_|jdur4|�t��n|��dSrB)Z	cancelledr(r$r%rT�BrokenPipeErrorrI)r-rzrrrr��s
z(_ProactorWritePipeTransport._pipe_closed)r8r_r`rr�rcrrr3rr��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*rg)r-r.rr/�addressr0r1r3rrr�s

z#_ProactorDatagramTransport.__init__cCst||�dSrB�rrArrrr�sz%_ProactorDatagramTransport._set_extracCstdd�|jD��S)Ncss|]\}}t|�VqdSrB)r;)�.0rl�_rrr�	<genexpr>�rrzC_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)rPrr�r�r�r�r��
ValueErrorr'rr�rrr#r9r%r�r�)r-rl�addrrrr�sendto�s&�
�

z!_ProactorDatagramTransport.sendtoc
Csz�|jrWdSd|_|r |��|jr2|jrN|jrN|jrH|j�|jd�WdS|j�	�\}}|jdur||jj
�|j|�|_n|jj
j
|j||d�|_Wn^ty�}z|j�|�WYd}~nNd}~0ty�}z|�|d�WYd}~n d}~00|j�|j�|��dS)N)r�z'Fatal write error on datagram transport)r'r%rsr#r�r(rr*rG�popleftrtr�r r�rQr+�error_received�	ExceptionrVryr�r�)r-rzrlr�rUrrrr��s2
�� "z(_ProactorDatagramTransport._loop_writingc
Cs|d}�zZz�|jr*WW|r&|j�||�dSd|_|dur�|��}|jrdd}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�y.|j�s*�Yn0|jdu�rJ|j�|j�W|�rx|j�||�n|�rv|j�||�0dSrB)r'r+Zdatagram_receivedr$rsr(r�rrtrur �max_sizeZrecvfromrQr�rrxryrg)r-rzrlr��resrUrrrrgsT$��
�
��
 �z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N)r8r_r`r�rrr^r�r�r�rgrcrrr3rr��s�

!r�c@seZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportcCsdS)NFrrDrrrr�Ksz*_ProactorDuplexPipeTransport.can_write_eofcCst�dSrB)�NotImplementedErrorrDrrrr�Nsz&_ProactorDuplexPipeTransport.write_eofN)r8r_r`r�r�rrrrr�Fsr�cs>eZdZejjZd
�fdd�	Zdd�Zdd�Z	dd	�Z
�ZS)�_ProactorSocketTransportNcs$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`rZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerrr�r�rcrrr3rr�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rRr4r8rt�	_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)rdr�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_pipertrIr�rrDr3rrrI�s

zBaseProactorEventLoop.closec�s|j�||�IdHSrB)rtru)r-r�nrrr�	sock_recv�szBaseProactorEventLoop.sock_recvc�s|j�||�IdHSrB)rtZ	recv_into)r-rZbufrrr�sock_recv_into�sz$BaseProactorEventLoop.sock_recv_intoc�s|j�||�IdHSrB)rtr�)r-rrlrrr�sock_sendall�sz"BaseProactorEventLoop.sock_sendallc�s|j�||�IdHSrB)rtZconnect)r-rr�rrr�sock_connect�sz"BaseProactorEventLoop.sock_connectc�s|j�|�IdHSrB)rt�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�seekrt�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)rhrir�Z
sock_sendfiler r�rm)r-Ztranspr�r�r�rmrrr�_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.)
rsr�rtrur�rrxrnrorprSry�_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)rsr�rrRr�r�r�rtr�rQr:rSrrrIrrxr�ry)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:rHrt�
_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�rcrrr3rrlsN
�
���
�
�
�


�
+r)#�__all__r�r�r
rar�r�r��rrrrrr	r
r�logrrZ_FlowControlMixinZ
BaseTransportrZ
ReadTransportrdZWriteTransportr{r�ZDatagramTransportr�Z	Transportr�r�Z
BaseEventLooprrrrr�<module>sT���n���

?>