AlkantarClanX12

Your IP : 18.188.183.21


Current Path : /opt/alt/python37/lib64/python3.7/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/asyncio/__pycache__/streams.cpython-37.opt-2.pyc

B

YI~d`�@sdZddlZeed�red7ZddlmZddlmZddlmZdd	lmZdd
l	m
Z
dZGdd
�d
e�Z
Gdd�de�Zd!ded�dd�Zd"ded�dd�Zeed�r�d#ded�dd�Zd$ded�dd�ZGdd�dej�ZGdd�deej�ZGdd�d�ZGdd �d �ZdS)%)�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�IncompleteReadError�LimitOverrunError�NZAF_UNIX)�open_unix_connection�start_unix_server�)�
coroutines)�events)�	protocols)�logger)�sleepics$eZdZ�fdd�Zdd�Z�ZS)rcs,t��t|��d|�d��||_||_dS)Nz bytes read on a total of z expected bytes)�super�__init__�len�partial�expected)�selfrr)�	__class__��4/opt/alt/python37/lib64/python3.7/asyncio/streams.pyrszIncompleteReadError.__init__cCst|�|j|jffS)N)�typerr)rrrr�
__reduce__#szIncompleteReadError.__reduce__)�__name__�
__module__�__qualname__rr�
__classcell__rr)rrrsrcs$eZdZ�fdd�Zdd�Z�ZS)rcst��|�||_dS)N)rr�consumed)r�messager )rrrr-szLimitOverrunError.__init__cCst|�|jd|jffS)Nr)r�argsr )rrrrr1szLimitOverrunError.__reduce__)rrrrrrrr)rrr'sr)�loop�limitc	�sb|dkrt��}t||d�}t||d��|j�fdd�||f|�IdH\}}t|�||�}||fS)N)r$r#)r#cs�S)Nrr)�protocolrr�<lambda>M�z!open_connection.<locals>.<lambda>)r
�get_event_looprrZcreate_connectionr)	�host�portr#r$�kwds�reader�	transport�_�writerr)r%rr5s rc�s8�dkrt������fdd�}�j|||f|�IdHS)Ncst��d�}t|��d�}|S)N)r$r#)r#)rr)r,r%)�client_connected_cbr$r#rr�factorylszstart_server.<locals>.factory)r
r(Z
create_server)r0r)r*r#r$r+r1r)r0r$r#rrRsrc�s`|dkrt��}t||d�}t||d��|j�fdd�|f|�IdH\}}t|�||�}||fS)N)r$r#)r#cs�S)Nrr)r%rrr&�r'z&open_unix_connection.<locals>.<lambda>)r
r(rrZcreate_unix_connectionr)�pathr#r$r+r,r-r.r/r)r%rr	xsr	c�s6�dkrt������fdd�}�j||f|�IdHS)Ncst��d�}t|��d�}|S)N)r$r#)r#)rr)r,r%)r0r$r#rrr1�sz"start_unix_server.<locals>.factory)r
r(Zcreate_unix_server)r0r2r#r$r+r1r)r0r$r#rr
�sr
c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�FlowControlMixinNcCs0|dkrt��|_n||_d|_d|_d|_dS)NF)r
r(�_loop�_paused�
_drain_waiter�_connection_lost)rr#rrrr�szFlowControlMixin.__init__cCs d|_|j��rt�d|�dS)NTz%r pauses writing)r5r4�	get_debugr�debug)rrrr�
pause_writing�s
zFlowControlMixin.pause_writingcCsFd|_|j��rt�d|�|j}|dk	rBd|_|��sB|�d�dS)NFz%r resumes writing)r5r4r8rr9r6�done�
set_result)r�waiterrrr�resume_writing�s
zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|��r4dS|dkrH|�d�n
|�|�dS)NT)r7r5r6r;r<�
set_exception)r�excr=rrr�connection_lost�sz FlowControlMixin.connection_lostc�s<|jrtd��|jsdS|j}|j��}||_|IdHdS)NzConnection lost)r7�ConnectionResetErrorr5r6r4�
create_future)rr=rrr�
_drain_helper�s
zFlowControlMixin._drain_helper)N)rrrrr:r>rArDrrrrr3�s


	r3csJeZdZd�fdd�	Zdd�Z�fdd�Zdd	�Zd
d�Zdd
�Z�Z	S)rNcs6t�j|d�||_d|_||_d|_|j��|_dS)N)r#F)	rr�_stream_reader�_stream_writer�_client_connected_cb�	_over_sslr4rC�_closed)rZ
stream_readerr0r#)rrrr�szStreamReaderProtocol.__init__cCsd|j�|�|�d�dk	|_|jdk	r`t|||j|j�|_|�|j|j�}t�	|�r`|j�
|�dS)NZ
sslcontext)rE�
set_transport�get_extra_inforHrGrr4rFrZiscoroutineZcreate_task)rr-Zresrrr�connection_made�s


z$StreamReaderProtocol.connection_madecsr|jdk	r*|dkr|j��n|j�|�|j��sV|dkrJ|j�d�n|j�|�t��|�d|_d|_dS)N)	rE�feed_eofr?rIr;r<rrArF)rr@)rrrrA�s

z$StreamReaderProtocol.connection_lostcCs|j�|�dS)N)rE�	feed_data)r�datarrr�
data_receivedsz"StreamReaderProtocol.data_receivedcCs|j��|jrdSdS)NFT)rErMrH)rrrr�eof_receiveds
z!StreamReaderProtocol.eof_receivedcCs"|j}|��r|��s|��dS)N)rIr;�	cancelled�	exception)r�closedrrr�__del__szStreamReaderProtocol.__del__)NN)
rrrrrLrArPrQrUrrr)rrr�s		rc@sreZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddd�Zdd�ZdS)rcCs||_||_||_||_dS)N)�
_transport�	_protocol�_readerr4)rr-r%r,r#rrrrszStreamWriter.__init__cCs@|jjd|j��g}|jdk	r0|�d|j���d�d�|��S)Nz
transport=zreader=z<{}>� )rrrVrX�append�format�join)r�inforrr�__repr__&s
zStreamWriter.__repr__cCs|jS)N)rV)rrrrr-,szStreamWriter.transportcCs|j�|�dS)N)rV�write)rrOrrrr_0szStreamWriter.writecCs|j�|�dS)N)rV�
writelines)rrOrrrr`3szStreamWriter.writelinescCs
|j��S)N)rV�	write_eof)rrrrra6szStreamWriter.write_eofcCs
|j��S)N)rV�
can_write_eof)rrrrrb9szStreamWriter.can_write_eofcCs
|j��S)N)rV�close)rrrrrc<szStreamWriter.closecCs
|j��S)N)rV�
is_closing)rrrrrd?szStreamWriter.is_closingc�s|jjIdHdS)N)rWrI)rrrr�wait_closedBszStreamWriter.wait_closedNcCs|j�||�S)N)rVrK)r�name�defaultrrrrKEszStreamWriter.get_extra_infoc�sR|jdk	r |j��}|dk	r |�|j��r>td|jd�IdH|j��IdHdS)Nr)r#)rXrSrVrdrr4rWrD)rr@rrr�drainHs


zStreamWriter.drain)N)rrrrr^�propertyr-r_r`rarbrcrdrerKrhrrrrrs

rc@s�eZdZedfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd&dd�Zd'dd�Zd d!�Zd"d#�Zd$d%�ZdS)(rNcCsZ|dkrtd��||_|dkr*t��|_n||_t�|_d|_d|_d|_	d|_
d|_dS)NrzLimit cannot be <= 0F)�
ValueError�_limitr
r(r4�	bytearray�_buffer�_eof�_waiter�
_exceptionrVr5)rr$r#rrrraszStreamReader.__init__cCs�dg}|jr"|�t|j��d��|jr2|�d�|jtkrN|�d|j���|jrf|�d|j���|jr~|�d|j���|jr�|�d|j���|j	r�|�d�d	�
d
�|��S)Nrz bytes�eofzlimit=zwaiter=z
exception=z
transport=Zpausedz<{}>rY)rmrZrrnrk�_DEFAULT_LIMITrorprVr5r[r\)rr]rrrr^ts 


zStreamReader.__repr__cCs|jS)N)rp)rrrrrS�szStreamReader.exceptioncCs0||_|j}|dk	r,d|_|��s,|�|�dS)N)rprorRr?)rr@r=rrrr?�szStreamReader.set_exceptioncCs*|j}|dk	r&d|_|��s&|�d�dS)N)rorRr<)rr=rrr�_wakeup_waiter�s
zStreamReader._wakeup_waitercCs
||_dS)N)rV)rr-rrrrJ�szStreamReader.set_transportcCs*|jr&t|j�|jkr&d|_|j��dS)NF)r5rrmrkrV�resume_reading)rrrr�_maybe_resume_transport�sz$StreamReader._maybe_resume_transportcCsd|_|��dS)NT)rnrs)rrrrrM�szStreamReader.feed_eofcCs|jo|jS)N)rnrm)rrrr�at_eof�szStreamReader.at_eofcCst|sdS|j�|�|��|jdk	rp|jspt|j�d|jkrpy|j��Wntk
rhd|_YnXd|_dS)N�T)	rm�extendrsrVr5rrkZ
pause_reading�NotImplementedError)rrOrrrrN�s
zStreamReader.feed_datac�sX|jdk	rt|�d���|jr.d|_|j��|j��|_z|jIdHWdd|_XdS)NzF() called while another coroutine is already waiting for incoming dataF)ro�RuntimeErrorr5rVrtr4rC)rZ	func_namerrr�_wait_for_data�s	

zStreamReader._wait_for_datac
�s�d}t|�}y|�|�IdH}Wn�tk
rD}z|jSd}~XYnftk
r�}zH|j�||j�rx|jd|j|�=n
|j��|�	�t
|jd��Wdd}~XYnX|S)N�
r)r�	readuntilrrrrm�
startswithr �clearrurjr")r�sep�seplen�line�errr�readline�s
 zStreamReader.readliner|c�s�t|�}|dkrtd��|jdk	r(|j�d}x�t|j�}|||kr||j�||�}|dkr\P|d|}||jkr|td|��|jr�t|j�}|j�	�t
|d��|�d�IdHq.W||jkr�td|��|jd||�}|jd||�=|��t|�S)Nrz,Separator should be at least one-byte string���rz2Separator is not found, and chunk exceed the limitr}z2Separator is found, but chunk is longer than limit)
rrjrprm�findrkrrn�bytesrrr{ru)rZ	separatorr��offset�buflenZisep�chunkrrrr}�s:






zStreamReader.readuntilr�c�s�|jdk	r|j�|dkrdS|dkrZg}x&|�|j�IdH}|sBP|�|�q*Wd�|�S|jsv|jsv|�d�IdHt|jd|��}|jd|�=|�	�|S)Nrr'�read)
rpr�rkrZr\rmrnr{r�ru)r�nZblocks�blockrOrrrr�Ws$

zStreamReader.readc�s�|dkrtd��|jdk	r |j�|dkr,dSxFt|j�|krr|jr`t|j�}|j��t||��|�d�IdHq.Wt|j�|kr�t|j�}|j��nt|jd|��}|jd|�=|�	�|S)Nrz*readexactly size can not be less than zeror'�readexactly)
rjrprrmrnr�rrr{ru)rr�Z
incompleterOrrrr��s&




zStreamReader.readexactlycCs|S)Nr)rrrr�	__aiter__�szStreamReader.__aiter__c�s|��IdH}|dkrt�|S)Nr')r��StopAsyncIteration)r�valrrr�	__anext__�szStreamReader.__anext__)r|)r�)rrrrrrr^rSr?rsrJrurMrvrNr{r�r}r�r�r�r�rrrrr_s"	
[
2)r)NN)NN)N)N)�__all__Zsocket�hasattr�rr
r�logrZtasksrrr�EOFErrorr�	Exceptionrrrr	r
ZProtocolr3rrrrrrr�<module>s0
"
A@K