ok

Mini Shell

Direktori : /proc/self/root/proc/self/root/lib64/python3.6/asyncio/__pycache__/
Upload File :
Current File : //proc/self/root/proc/self/root/lib64/python3.6/asyncio/__pycache__/proactor_events.cpython-36.pyc

3


 \�O�@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�eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ejrXdd�Z
ddd�Zdd�Zdd�Zdd�Z�ZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncs�t�j||�|j|�||_||_||_d|_d|_d|_d|_	d|_
d|_d|_|jdk	rh|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__��'/usr/lib64/python3.6/proactor_events.pyr
s$



z#_ProactorBasePipeTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jdk	rN|jd|jj��|jdk	rh|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r@|jdkr@|jj|jd�|jdk	rZ|jj�d|_dS)NTr)	rrrrrr�_call_connection_lostr�cancel)rr#r#r$�closeNs

z _ProactorBasePipeTransport.closecCs*|jdk	r&tjd|t|d�|j�dS)Nzunclosed transport %r)�source)r�warnings�warn�ResourceWarningr7)rr#r#r$�__del__]s
z"_ProactorBasePipeTransport.__del__�Fatal error on pipe transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)�exc_info)�message�	exceptionZ	transportr)
�
isinstancerZ_FATAL_ERROR_IGNOREr�	get_debugr
�debug�call_exception_handlerr�_force_close)r�excr?r#r#r$�_fatal_errorcs
z'_ProactorBasePipeTransport._fatal_errorcCsj|jr
dSd|_|jd7_|jr4|jj�d|_|jrJ|jj�d|_d|_d|_|jj|j	|�dS)NTrr)
rrrr6rrrrrr5)rrFr#r#r$rEps

z'_ProactorBasePipeTransport._force_closecCs^z|jj|�Wdt|jd�r,|jjtj�|jj�d|_|j}|dk	rX|j	�d|_XdS)N�shutdown)
rZconnection_lost�hasattrrrH�socketZ	SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s
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)NNN)r=)r(�
__module__�__qualname__�__doc__r
r/rr2r3r4r7rZPY34r<rGrEr5rL�
__classcell__r#r#)r"r$rs

rcs<eZdZdZd�fdd�	Zdd�Zdd�Zdd	d
�Z�ZS)
�_ProactorReadPipeTransportzTransport for read pipes.Ncs4t�j||||||�d|_d|_|jj|j�dS)NF)rr
�_paused�_reschedule_on_resumerr�
_loop_reading)rrrrrr r!)r"r#r$r
�sz#_ProactorReadPipeTransport.__init__cCs0|js|jrdSd|_|jj�r,tjd|�dS)NTz%r pauses reading)rrRrrBr
rC)rr#r#r$�
pause_reading�s

z(_ProactorReadPipeTransport.pause_readingcCsP|js|jrdSd|_|jr6|jj|j|j�d|_|jj�rLtj	d|�dS)NFz%r resumes reading)
rrRrSrrrTrrBr
rC)rr#r#r$�resume_reading�s
z)_ProactorReadPipeTransport.resume_readingcCs�|jrd|_dSd}�z@yf|dk	rN|j|ks@|jdkr<|js@t�d|_|j�}|jr\d}dS|dkrhdS|jjj|j	d�|_Wn�t
k
r�}z2|js�|j|d�n|jj�r�t
jddd�WYdd}~Xn�tk
r�}z|j|�WYdd}~Xn^tk
�r$}z|j|d�WYdd}~Xn0tjk
�rD|j�s@�YnX|jj|j�Wd|�rl|jj|�n:|dk	�r�|jj��r�t
jd|�|jj�}|�s�|j�XdS)NT�iz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSrr�AssertionError�resultr�	_proactor�recvr�ConnectionAbortedErrorrGrBr
rC�ConnectionResetErrorrE�OSErrorr�CancelledError�add_done_callbackrTrZ
data_receivedZeof_receivedr7)r�fut�datarFZ	keep_openr#r#r$rT�sL



z(_ProactorReadPipeTransport._loop_reading)NNN)N)	r(rMrNrOr
rUrVrTrPr#r#)r"r$rQ�s
rQc@s:eZdZdZdd�Zd
dd�Zdd�Zd	d
�Zdd�ZdS)�_ProactorBaseWritePipeTransportzTransport for write pipes.cCs�t|tttf�s&dt|�j}t|��|jr4td��|s<dS|j	rj|j	t
jkrXtj
d�|j	d7_	dS|jdkr�|jdks�t�|jt|�d�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.r)rb)rA�bytes�	bytearray�
memoryview�typer(�	TypeErrorr�RuntimeErrorrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningrrrX�
_loop_writing�_maybe_pause_protocol�extend)rrb�msgr#r#r$�write�s*



z%_ProactorBaseWritePipeTransport.writeNcCs4y�||jkst�d|_d|_|r(|j�|dkr<|j}d|_|st|jrV|jj|jd�|j	rj|j
jtj
�|j�n\|jjj|j
|�|_|jj�s�|jdks�t�t|�|_|jj|j�|j�n|jj|j�Wn\tk
�r}z|j|�WYdd}~Xn0tk
�r.}z|j|d�WYdd}~XnXdS)Nrz#Fatal write error on pipe transport)rrXrrYrrrrr5rrrHrJ�SHUT_WRZ_maybe_resume_protocolrZ�send�doner+r`rkrlr]rEr^rG)r�frbrFr#r#r$rk
s4



z-_ProactorBaseWritePipeTransport._loop_writingcCsdS)NTr#)rr#r#r$�
can_write_eof0sz-_ProactorBaseWritePipeTransport.can_write_eofcCs|j�dS)N)r7)rr#r#r$�	write_eof3sz)_ProactorBaseWritePipeTransport.write_eofcCs|jd�dS)N)rE)rr#r#r$�abort6sz%_ProactorBaseWritePipeTransport.abort)NN)	r(rMrNrOrorkrtrurvr#r#r#r$rc�s$
#rccs$eZdZ�fdd�Zdd�Z�ZS)�_ProactorWritePipeTransportcs4t�j||�|jjj|jd�|_|jj|j�dS)N�)	rr
rrZr[rrr`�_pipe_closed)r�args�kw)r"r#r$r
;sz$_ProactorWritePipeTransport.__init__cCsv|j�rdS|j�dkst�|jr4|jdks0t�dS||jksLt||jf��d|_|jdk	rj|jt��n|j�dS)NrW)	Z	cancelledrYrXrrrrE�BrokenPipeErrorr7)rrar#r#r$ry@s
z(_ProactorWritePipeTransport._pipe_closed)r(rMrNr
ryrPr#r#)r"r$rw:srwc@s eZdZdZdd�Zdd�ZdS)�_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFr#)rr#r#r$rtUsz*_ProactorDuplexPipeTransport.can_write_eofcCst�dS)N)�NotImplementedError)rr#r#r$ruXsz&_ProactorDuplexPipeTransport.write_eofN)r(rMrNrOrtrur#r#r#r$r}Psr}cs:eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Z�ZS)�_ProactorSocketTransportz Transport for connected sockets.Ncs$t�j||||||�tj|�dS)N)rr
rZ_set_nodelay)rrrrrr r!)r"r#r$r
asz!_ProactorSocketTransport.__init__cCs�||jd<y|j�|jd<Wn4tjtfk
rP|jj�rLtjd|dd�YnXd|jkr�y|j	�|jd<Wn4tjtfk
r�|jj�r�tjd|dd�YnXdS)NrJZsocknamezgetsockname() failed on %rT)r>�peernamezgetpeername() failed on %r)
r1ZgetsocknamerJ�error�AttributeErrorrrBr
rjZgetpeername)rrr#r#r$rfs



z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rtvsz&_ProactorSocketTransport.can_write_eofcCs2|js|jrdSd|_|jdkr.|jjtj�dS)NT)rrrrrHrJrp)rr#r#r$ruys

z"_ProactorSocketTransport.write_eof)NNN)	r(rMrNrOr
rrtrurPr#r#)r"r$r\srcs�eZdZ�fdd�Zd-dd�Zd.ddddd�dd	�Zd/d
d�Zd0dd
�Zd1dd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd2d d!�Zd"d#�Zd3d%d&�Zd'd(�Zd)d*�Zd+d,�Z�ZS)4rcsHt�j�tjd|jj�||_||_d|_i|_	|j
|�|j�dS)NzUsing proactor: %s)rr
r
rCr"r(rZ�	_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�s
z,BaseProactorEventLoop._make_socket_transportF)�server_side�server_hostnamer r!c
Cs<tj�std��tj||||||�}	t|||	||d�|	jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler~ZSSLProtocolrZ_app_transport)
rZrawsockr�
sslcontextrr�r�r r!Zssl_protocolr#r#r$�_make_ssl_transport�s
z)BaseProactorEventLoop._make_ssl_transportcCst|||||�S)N)r})rrrrr r#r#r$�_make_duplex_pipe_transport�sz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||�S)N)rQ)rrrrr r#r#r$�_make_read_pipe_transport�sz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||�S)N)rw)rrrrr r#r#r$�_make_write_pipe_transport�sz0BaseProactorEventLoop._make_write_pipe_transportcsP|j�rtd��|j�rdS|j�|j�|jj�d|_d|_t�j�dS)Nz!Cannot close a running event loop)	Z
is_runningri�	is_closed�_stop_accept_futures�_close_self_piperZr7r�r)r)r"r#r$r7�s
zBaseProactorEventLoop.closecCs|jj||�S)N)rZr[)rr�nr#r#r$�	sock_recv�szBaseProactorEventLoop.sock_recvcCs|jj||�S)N)rZrq)rrrbr#r#r$�sock_sendall�sz"BaseProactorEventLoop.sock_sendallcCs|jj||�S)N)rZZconnect)rrZaddressr#r#r$�sock_connect�sz"BaseProactorEventLoop.sock_connectcCs|jj|�S)N)rZ�accept)rrr#r#r$�sock_accept�sz!BaseProactorEventLoop.sock_acceptcCst�dS)N)r~)rr#r#r$�_socketpair�sz!BaseProactorEventLoop._socketpaircCsL|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_pipecCsF|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�y$|dk	r|j�|jj|jd�}WnHtjk
r:dStk
rl}z|jd||d��WYdd}~XnX||_|j	|j
�dS)Niz.Error on reading from the event loop self pipe)r?r@r)rYrZr[r�rr_�	ExceptionrDr�r`r�)rrsrFr#r#r$r��sz(BaseProactorEventLoop._loop_self_readingcCs|jjd�dS)N�)r�rq)rr#r#r$�_write_to_self�sz$BaseProactorEventLoop._write_to_self�dcs&d������fdd�	��j��dS)Ncs"y�|dk	rl|j�\}}�jr,tjd�||���}�dk	rV�j||�dd|i�d�n�j||d|i�d��j�rxdS�jj��}Wn~t	k
r�}zD�j
�dkr��jd|�d���j�n�jr�tjd	�dd
�WYdd}~Xn8t
jk
�r�j�YnX|�j�j
�<|j��dS)Nz#%r got a new connection from %r: %rTr�)r�r r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>���)rYZ_debugr
rCr�r�r�rZr�r^r*rDr7rr_r�r`)rsZconnZaddrrrF)r�protocol_factoryrr!rr�r#r$r�s>


z2BaseProactorEventLoop._start_serving.<locals>.loop)N)r)rr�rr�r!Zbacklogr#)rr�rr!rr�r$�_start_serving�s$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ
event_listr#r#r$�_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jj�D]}|j�qW|jj�dS)N)r��valuesr6�clear)rZfuturer#r#r$r�$sz*BaseProactorEventLoop._stop_accept_futurescCs |j�|jj|�|j�dS)N)r�rZ�
_stop_servingr7)rrr#r#r$r�)sz#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr�)r(rMrNr
r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�rPr#r#)r"r$r�s4







()rO�__all__rJr9�rrrrrr	�logr
Z_FlowControlMixinZ
BaseTransportrZ
ReadTransportrQZWriteTransportrcrwZ	Transportr}rZ
BaseEventLooprr#r#r#r$�<module>s2MT
#

Zerion Mini Shell 1.0