AlkantarClanX12

Your IP : 3.146.152.119


Current Path : /opt/alt/python35/lib64/python3.5/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/asyncio/__pycache__/proactor_events.cpython-35.pyc



��Yf�N�@s_dZdgZddlZddlZddlmZddlmZddlmZddlmZdd	lm	Z	dd
lm
Z
ddlmZGdd
�d
e
j
e
j�ZGdd�dee
j�ZGdd�dee
j�ZGdd�de�ZGdd�deee
j�ZGdd�deee
j�ZGdd�dej�ZdS)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)�compat)�	constants)�futures)�sslproto)�
transports)�loggercs�eZdZdZddd�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejr�dd�Z
ddd�Zdd�Zdd�Zdd�Z�S)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t�j||�|j|�||_||_||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	r�|jj
�|jj|jj|�|dk	r�|jjtj|d�dS)NrF)�super�__init__�
_set_extra�_sock�	_protocol�_server�_buffer�	_read_fut�
_write_fut�_pending_write�
_conn_lost�_closing�_eof_writtenZ_attach�_loop�	call_soonZconnection_maderZ_set_result_unless_cancelled)�self�loop�sock�protocol�waiter�extra�server)�	__class__��</opt/alt/python35/lib64/python3.5/asyncio/proactor_events.pyr
s$
										
z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr.|jd�n|jrD|jd�|jdk	rm|jd|jj��|jdk	r�|jd|j�|jdk	r�|jd|j�|jr�t	|j�}|jd|�|j
r�|jd�dd	j|�S)
N�closed�closingzfd=%szread=%szwrite=%rzwrite_bufsize=%szEOF writtenz<%s>� )r"�__name__r�appendr�filenorrr�lenr�join)r�info�bufsizer#r#r$�__repr__/s"	
		
z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)N�pipe)�_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs
||_dS)N)r)rrr#r#r$�set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$�get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$�
is_closingKsz%_ProactorBasePipeTransport.is_closingcCs}|jr
dSd|_|jd7_|jrT|jdkrT|jj|jd�|jdk	ry|jj�d|_dS)NTr)	rrrrrr�_call_connection_lostr�cancel)rr#r#r$�closeNs		
z _ProactorBasePipeTransport.closecCs1|jdk	r-tjd|t�|j�dS)Nzunclosed transport %r)r�warnings�warn�ResourceWarningr7)rr#r#r$�__del__]sz"_ProactorBasePipeTransport.__del__zFatal error on pipe transportc	Csyt|tj�r=|jj�rhtjd||dd�n+|jjd|d|d|d|ji�|j	|�dS)Nz%r: %s�exc_infoT�message�	exceptionZ	transportr)
�
isinstancerZ_FATAL_ERROR_IGNOREr�	get_debugr
�debug�call_exception_handlerr�_force_close)r�excr=r#r#r$�_fatal_errorbs	z'_ProactorBasePipeTransport._fatal_errorcCs�|jr
dSd|_|jd7_|jrD|jj�d|_|jrc|jj�d|_d|_d|_|jj|j	|�dS)NTrr)
rrrr6rrrrrr5)rrDr#r#r$rCos			
		
			z'_ProactorBasePipeTransport._force_closecCsz|jj|�Wdt|jd�r<|jjtj�|jj�d|_|j}|dk	rz|j	�d|_XdS)N�shutdown)
rZconnection_lost�hasattrrrF�socketZ	SHUT_RDWRr7rZ_detach)rrDr!r#r#r$r5~s
		
z0_ProactorBasePipeTransport._call_connection_lostcCs/|j}|jdk	r+|t|j�7}|S)N)rrr+)r�sizer#r#r$�get_write_buffer_size�s	z0_ProactorBasePipeTransport.get_write_buffer_size)r(�
__module__�__qualname__�__doc__r
r/rr2r3r4r7rZPY34r;rErCr5rJr#r#)r"r$rs	
rcsXeZdZdZddd�fdd�Zdd�Zdd�Zdd	d
�Z�S)�_ProactorReadPipeTransportzTransport for read pipes.Ncs?t�j||||||�d|_|jj|j�dS)NF)rr
�_pausedrr�
_loop_reading)rrrrrr r!)r"r#r$r
�s	z#_ProactorReadPipeTransport.__init__cCsV|jrtd��|jr*td��d|_|jj�rRtjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)r�RuntimeErrorrOrr@r
rA)rr#r#r$�
pause_reading�s			z(_ProactorReadPipeTransport.pause_readingcCsg|jstd��d|_|jr+dS|jj|j|j�|jj�rctj	d|�dS)Nz
Not pausedFz%r resumes reading)
rOrQrrrrPrr@r
rA)rr#r#r$�resume_reading�s			z)_ProactorReadPipeTransport.resume_readingcCs|jr
dSd}z�y�|dk	rg|j|ksR|jdkrL|jsRt�d|_|j�}|jrzd}dS|dkr�dS|jjj|jd�|_Wn�t	k
r}zC|js�|j
|d�n"|jj�r�tj
ddd�WYdd}~Xn�tk
r?}z|j|�WYdd}~Xnhtk
rs}z|j
|d�WYdd}~Xn4tjk
r�|js��YnX|jj|j�Wd|r�|jj|�nJ|dk	r|jj�r�tj
d|�|jj�}|s|j�XdS)N�iz"Fatal read error on pipe transportz*Read error on pipe transport while closingr<Tz%r received EOF)rOrr�AssertionError�resultr�	_proactor�recvr�ConnectionAbortedErrorrEr@r
rA�ConnectionResetErrorrC�OSErrorr�CancelledError�add_done_callbackrPrZ
data_receivedZeof_receivedr7)r�fut�datarDZ	keep_openr#r#r$rP�sJ			"	"	z(_ProactorReadPipeTransport._loop_reading)r(rKrLrMr
rRrSrPr#r#)r"r$rN�s	
rNc@sXeZdZdZdd�Zdddd�Zdd�Zd	d
�Zdd�ZdS)
�_ProactorBaseWritePipeTransportzTransport for write pipes.cCst|tttf�s7dt|�j}t|��|jrLtd��|sVdS|j	r�|j	t
jkr~tj
d�|j	d7_	dS|jdkr�|jdks�t�|jdt|��n?|js�t|�|_|j�n|jj|�|j�dS)Nz3data argument must be a bytes-like object, not '%s'zwrite_eof() already calledzsocket.send() raised exception.rr_)r?�bytes�	bytearray�
memoryview�typer(�	TypeErrorrrQrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningrrrU�
_loop_writing�_maybe_pause_protocol�extend)rr_�msgr#r#r$�write�s*		
	
z%_ProactorBaseWritePipeTransport.writeNcCs�y+||jkst�d|_d|_|r:|j�|dkrX|j}d|_|s�|jr}|jj|jd�|j	r�|j
jtj
�|j�n�|jjj|j
|�|_|jj�s|jdks�t�t|�|_|jj|j�|j�n|jj|j�Wnftk
r_}z|j|�WYdd}~Xn5tk
r�}z|j|d�WYdd}~XnXdS)Nrz#Fatal write error on pipe transport)rrUrrVrrrrr5rrrFrH�SHUT_WRZ_maybe_resume_protocolrW�send�doner+r]rgrhrZrCr[rE)r�fr_rDr#r#r$rgs4		
				

z-_ProactorBaseWritePipeTransport._loop_writingcCsdS)NTr#)rr#r#r$�
can_write_eof/sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|j�dS)N)r7)rr#r#r$�	write_eof2sz)_ProactorBaseWritePipeTransport.write_eofcCs|jd�dS)N)rC)rr#r#r$�abort5sz%_ProactorBaseWritePipeTransport.abort)	r(rKrLrMrkrgrprqrrr#r#r#r$r`�s$#r`cs.eZdZ�fdd�Zdd�Z�S)�_ProactorWritePipeTransportcsHt�j||�|jjj|jd�|_|jj|j�dS)N�)	rr
rrWrXrrr]�_pipe_closed)r�args�kw)r"r#r$r
:sz$_ProactorWritePipeTransport.__init__cCs�|j�rdS|j�dks(t�|jrJ|jdksFt�dS||jksnt||jf��d|_|jdk	r�|jt��n
|j�dS)NrT)	Z	cancelledrVrUrrrrC�BrokenPipeErrorr7)rr^r#r#r$ru?s	$	z(_ProactorWritePipeTransport._pipe_closed)r(rKrLr
rur#r#)r"r$rs9srsc@s.eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFr#)rr#r#r$rpTsz*_ProactorDuplexPipeTransport.can_write_eofcCs
t�dS)N)�NotImplementedError)rr#r#r$rqWsz&_ProactorDuplexPipeTransport.write_eofN)r(rKrLrMrprqr#r#r#r$ryOsryc@s:eZdZdZdd�Zdd�Zdd�ZdS)	�_ProactorSocketTransportz Transport for connected sockets.cCs�||jd<y|j�|jd<Wn@tjtfk
rf|jj�rbtjd|dd�YnXd|jkr�y|j	�|jd<Wn@tjtfk
r�|jj�r�tjd|dd�YnXdS)NrHZsocknamezgetsockname() failed on %rr<T�peernamezgetpeername() failed on %r)
r1ZgetsocknamerH�error�AttributeErrorrr@r
rfZgetpeername)rrr#r#r$r`s
		z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rppsz&_ProactorSocketTransport.can_write_eofcCsE|js|jrdSd|_|jdkrA|jjtj�dS)NT)rrrrrFrHrl)rr#r#r$rqss
	z"_ProactorSocketTransport.write_eofN)r(rKrLrMrrprqr#r#r#r$r{[sr{csNeZdZ�fdd�Zddddd�Zdddddd	dd
ddd�Zddd
d�Zdddd�Zdddd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd �Zd!d"�Zdd#d$�Zd%d&�Zddd'd(d)�Zd*d+�Zd,d-�Zd.d/�Z�S)0rcsbt�j�tjd|jj�||_||_d|_i|_	|j
|�|j�dS)NzUsing proactor: %s)rr
r
rAr"r(rW�	_selector�_self_reading_future�_accept_futuresZset_loop�_make_self_pipe)rZproactor)r"r#r$r
}s
				
zBaseProactorEventLoop.__init__NcCst||||||�S)N)r{)rrrrr r!r#r#r$�_make_socket_transport�sz,BaseProactorEventLoop._make_socket_transport�server_sideF�server_hostnamer r!c
CsYtj�std��tj||||||�}	t|||	d|d|�|	jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSLr r!)rZ_is_sslproto_availablerzZSSLProtocolr{Z_app_transport)
rZrawsockr�
sslcontextrr�r�r r!Zssl_protocolr#r#r$�_make_ssl_transport�s
z)BaseProactorEventLoop._make_ssl_transportcCst|||||�S)N)ry)rrrrr r#r#r$�_make_duplex_pipe_transport�sz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�S)N)rN)rrrrr r#r#r$�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�S)N)rs)rrrrr r#r#r$�_make_write_pipe_transport�sz0BaseProactorEventLoop._make_write_pipe_transportcsl|j�rtd��|j�r(dS|j�|j�|jj�d|_d|_t�j�dS)Nz!Cannot close a running event loop)	Z
is_runningrQ�	is_closed�_stop_accept_futures�_close_self_piperWr7rr)r)r"r#r$r7�s


		zBaseProactorEventLoop.closecCs|jj||�S)N)rWrX)rr�nr#r#r$�	sock_recv�szBaseProactorEventLoop.sock_recvcCs|jj||�S)N)rWrm)rrr_r#r#r$�sock_sendall�sz"BaseProactorEventLoop.sock_sendallcCs|jj||�S)N)rWZconnect)rrZaddressr#r#r$�sock_connect�sz"BaseProactorEventLoop.sock_connectcCs|jj|�S)N)rW�accept)rrr#r#r$�sock_accept�sz!BaseProactorEventLoop.sock_acceptcCs
t�dS)N)rz)rr#r#r$�_socketpair�sz!BaseProactorEventLoop._socketpaircCsd|jdk	r%|jj�d|_|jj�d|_|jj�d|_|jd8_dS)Nr)r�r6�_ssockr7�_csock�
_internal_fds)rr#r#r$r��s
	
	
	z&BaseProactorEventLoop._close_self_pipecCs[|j�\|_|_|jjd�|jjd�|jd7_|j|j�dS)NFr)r�r�r�Zsetblockingr�r�_loop_self_reading)rr#r#r$r��s
z%BaseProactorEventLoop._make_self_pipecCs�y2|dk	r|j�|jj|jd�}Wn\tjk
rMdSYn]tk
r�}z$|jddd|d|i�WYdd}~XnX||_|j	|j
�dS)Nir=z.Error on reading from the event loop self piper>r)rVrWrXr�rr\�	ExceptionrBr�r]r�)rrorDr#r#r$r��s
 	z(BaseProactorEventLoop._loop_self_readingcCs|jjd�dS)Ns)r�rm)rr#r#r$�_write_to_self�sz$BaseProactorEventLoop._write_to_self�dcs5d������fdd���j��dS)Ncs�y�|dk	r�|j�\}}�jr@tjd�||���}�dk	r��j||�dddd|id��n"�j||dd|id���j�r�dS�jj��}Wn�t	k
rL}zb�j
�dkr�jdd	d
|d�i��j�n�jr:tjd�d
d�WYdd}~Xn?t
jk
rj�j�Yn!X|�j�j
�<|j��dS)Nz#%r got a new connection from %r: %rr�Tr r|r!rr=zAccept failed on a socketr>rHzAccept failed on socket %rr<���)rVZ_debugr
rAr�r�r�rWr�r[r*rBr7rr\r�r])roZconnZaddrrrD)r�protocol_factoryrr!rr�r#r$r�s>		
		

		z2BaseProactorEventLoop._start_serving.<locals>.loop)r)rr�rr�r!Zbacklogr#)rr�rr!rr�r$�_start_serving�s$$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ
event_listr#r#r$�_process_eventssz%BaseProactorEventLoop._process_eventscCs5x!|jj�D]}|j�qW|jj�dS)N)r��valuesr6�clear)rZfuturer#r#r$r�sz*BaseProactorEventLoop._stop_accept_futurescCs(|j�|jj|�|j�dS)N)r�rW�
_stop_servingr7)rrr#r#r$r�#s
z#BaseProactorEventLoop._stop_serving)r(rKrLr
r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�r#r#)r"r$r{s4

()rM�__all__rHr8�rrrrrr	�logr
Z_FlowControlMixinZ
BaseTransportrZ
ReadTransportrNZWriteTransportr`rsZ	Transportryr{Z
BaseEventLooprr#r#r#r$�<module>s0	�MT