AlkantarClanX12

Your IP : 3.15.228.171


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



���]�N�@sYdgZddlZddlZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
l
mZGdd�de	je	j
�ZGd
d�dee	j�ZGdd�dee	j�ZGdd�de�ZGdd�deee	j�ZGdd�deee	j�ZGdd�dej�ZdS)�BaseProactorEventLoop�N�)�base_events)�compat)�	constants)�futures)�sslproto)�
transports)�loggercs�eZdZddd�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
jr�dd�Zddd�Z
dd�Zdd�Zdd�Z�S)�_ProactorBasePipeTransportNcs�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__��4/opt/alt/python35/lib64/python3.5/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�socket�	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__r
r/rr2r3r4r7rZPY34r;rErCr5rKr#r#)r"r$rs	
rcsReZdZddd�fdd�Zdd�Zdd�Zddd	�Z�S)
�_ProactorReadPipeTransportNcs?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}zhyf|dk	r:d|_|j�}|jrMd}dS|dkr]dS|jjj|jd�|_Wn�tk
r�}zC|js�|j	|d�n"|jj
�r�tjddd�WYdd}~Xn�t
k
r}z|j|�WYdd}~Xnhtk
rF}z|j	|d�WYdd}~Xn4tjk
rf|jsb�YnX|jj|j�Wd|r�|jj|�nJ|dk	r�|jj
�r�tjd|�|jj�}|s�|j�XdS)N�iz"Fatal read error on pipe transportz*Read error on pipe transport while closingr<Tz%r received EOF)rOr�resultrr�	_proactor�recvr�ConnectionAbortedErrorrEr@r
rA�ConnectionResetErrorrC�OSErrorr�CancelledError�add_done_callbackrPrZ
data_receivedZeof_receivedr7)r�fut�datarDZ	keep_openr#r#r$rP�sF			"	"	z(_ProactorReadPipeTransport._loop_reading)r(rLrMr
rRrSrPr#r#)r"r$rN�s
	
rNc@sReZdZdd�Zdddd�Zdd�Zdd	�Zd
d�ZdS)�_ProactorBaseWritePipeTransportcCs�t|tttf�s7dt|�j}t|��|jrLtd��|sVdS|j	r�|j	t
jkr~tj
d�|j	d7_	dS|jdkr�|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
�warningr�
_loop_writingr�_maybe_pause_protocol�extend)rr^�msgr#r#r$�write�s(		
	
z%_ProactorBaseWritePipeTransport.writeNcCsnyd|_d|_|r%|j�|dkrC|j}d|_|s�|jrh|jj|jd�|jr�|j	j
tj�|j
�no|jjj|j	|�|_|jj�s�t|�|_|jj|j�|j�n|jj|j�Wnftk
r5}z|j|�WYdd}~Xn5tk
ri}z|j|d�WYdd}~XnXdS)Nrz#Fatal write error on pipe transport)rrrUrrrrr5rrrFrH�SHUT_WRZ_maybe_resume_protocolrV�send�doner+r\rfrgrYrCrZrE)r�fr^rDr#r#r$rfs0		
				

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(rLrMrjrfrorprqr#r#r#r$r_�s
$#r_cs.eZdZ�fdd�Zdd�Z�S)�_ProactorWritePipeTransportcsHt�j||�|jjj|jd�|_|jj|j�dS)N�)	rr
rrVrWrrr\�_pipe_closed)r�args�kw)r"r#r$r
:sz$_ProactorWritePipeTransport.__init__cCsV|j�rdS|jrdSd|_|jdk	rH|jt��n
|j�dS)N)�	cancelledrrrrC�BrokenPipeErrorr7)rr]r#r#r$rt?s		z(_ProactorWritePipeTransport._pipe_closed)r(rLrMr
rtr#r#)r"r$rr9srrc@s(eZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportcCsdS)NFr#)rr#r#r$roTsz*_ProactorDuplexPipeTransport.can_write_eofcCs
t�dS)N)�NotImplementedError)rr#r#r$rpWsz&_ProactorDuplexPipeTransport.write_eofN)r(rLrMrorpr#r#r#r$ryOsryc@s4eZdZdd�Zdd�Zdd�ZdS)�_ProactorSocketTransportcCs�||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)
r1�getsocknamerH�error�AttributeErrorrr@r
re�getpeername)rrr#r#r$r`s
		z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$ropsz&_ProactorSocketTransport.can_write_eofcCsE|js|jrdSd|_|jdkrA|jjtj�dS)NT)rrrrrFrHrk)rr#r#r$rpss
	z"_ProactorSocketTransport.write_eofN)r(rLrMrrorpr#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(rV�	_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)rr)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_piperVr7r�r)r)r"r#r$r7�s


		zBaseProactorEventLoop.closecCs|jj||�S)N)rVrW)rr�nr#r#r$�	sock_recv�szBaseProactorEventLoop.sock_recvcCs|jj||�S)N)rVrl)rrr^r#r#r$�sock_sendall�sz"BaseProactorEventLoop.sock_sendallcCs|jj||�S)N)rV�connect)rr�addressr#r#r$�sock_connect�sz"BaseProactorEventLoop.sock_connectcCs|jj|�S)N)rV�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��setblockingr�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)rUrVrWr�rr[�	ExceptionrBr�r\r�)rrnrDr#r#r$r��s
 	z(BaseProactorEventLoop._loop_self_readingcCs|jjd�dS)Ns)r�rl)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<���)rUZ_debugr
rAr�r�r�rVr�rZr*rBr7rr[r�r\)rn�conn�addrrrD)r�protocol_factoryrr!rr�r#r$r�s>		
		

		z2BaseProactorEventLoop._start_serving.<locals>.loop)r)rr�rr�r!�backlogr#)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)r�futurer#r#r$r�sz*BaseProactorEventLoop._stop_accept_futurescCs(|j�|jj|�|j�dS)N)r�rV�
_stop_servingr7)rrr#r#r$r�#s
z#BaseProactorEventLoop._stop_serving)r(rLrMr
r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�r#r#)r"r$r{s4

()�__all__rHr8�rrrrrr	�logr
Z_FlowControlMixinZ
BaseTransportrZ
ReadTransportrNZWriteTransportr_rrZ	Transportryr{Z
BaseEventLooprr#r#r#r$�<module>s.	�MT