AlkantarClanX12

Your IP : 3.148.108.144


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



���]���
@s�dgZddlZddlZddlZddlZddlZddlZyddlZWnek
r{dZYnXddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZdd	l	mZdd
l	mZddl	mZddlmZdd
lmZdd�Zeed�rFdd�Zndd�ZGdd�de
j�ZGdd�dejej�ZGdd�de�ZGdd�de�ZGdd�de�Z dS)�BaseSelectorEventLoop�N�)�base_events)�compat)�	constants)�events)�futures)�	selectors)�
transports)�sslproto)�	coroutine)�loggercCsAy|j|�}Wntk
r+dSYnXt|j|@�SdS)NF)�get_key�KeyError�boolr)�selector�fd�event�key�r�4/opt/alt/python35/lib64/python3.5/selector_events.py�_test_selector_event s

	r�TCP_NODELAYcCs\|jtjtjhkrX|jtjkrX|jtjkrX|jtjtj	d�dS)Nr)
�family�socket�AF_INET�AF_INET6�type�SOCK_STREAM�proto�IPPROTO_TCP�
setsockoptr)�sockrrr�_set_nodelay,sr#cCsdS)Nr)r"rrrr#2scs>eZdZd�fdd�Zddddddd�Zddd	d
ddddddd�Zdd	d
dddddd
d�Zddddd�Z�fdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdddd d!�Zdddd"d#�Zeddd$d%��Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zed@dA��Z dBdC�Z!dDdE�Z"dFdG�Z#dHdI�Z$dJdK�Z%dLdM�Z&dNdO�Z'�S)PrNcsat�j�|dkr%tj�}tjd|jj�||_|j	�t
j�|_dS)NzUsing selector: %s)
�super�__init__r	�DefaultSelectorr
�debug�	__class__�__name__�	_selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfr)r(rrr%<s
	
zBaseSelectorEventLoop.__init__�extra�servercCst||||||�S)N)�_SelectorSocketTransport)r/r"�protocol�waiterr0r1rrr�_make_socket_transportFsz,BaseSelectorEventLoop._make_socket_transport�server_sideF�server_hostnamec

Cs{tj�s:|j||||d|d|d|d|�Stj||||||�}	t|||	d|d|�|	jS)Nr6r7r0r1)rZ_is_sslproto_available�_make_legacy_ssl_transportZSSLProtocolr2Z_app_transport)
r/�rawsockr3�
sslcontextr4r6r7r0r1Zssl_protocolrrr�_make_ssl_transportKs

z)BaseSelectorEventLoop._make_ssl_transportc	
Cs"t|||||||||�	S)N)�_SelectorSslTransport)	r/r9r3r:r4r6r7r0r1rrrr8Zsz0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||�S)N)�_SelectorDatagramTransport)r/r"r3�addressr4r0rrr�_make_datagram_transportdsz.BaseSelectorEventLoop._make_datagram_transportcsh|j�rtd��|j�r(dS|j�t�j�|jdk	rd|jj�d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper$�closer*)r/)r(rrrCis


zBaseSelectorEventLoop.closecCs
t�dS)N)�NotImplementedError)r/rrr�_socketpairtsz!BaseSelectorEventLoop._socketpaircCsU|j|jj��|jj�d|_|jj�d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenorC�_csock�
_internal_fds)r/rrrrBws
	
	z&BaseSelectorEventLoop._close_self_pipecCsg|j�\|_|_|jjd�|jjd�|jd7_|j|jj�|j�dS)NFr)rErGrI�setblockingrJ�_add_readerrH�_read_from_self)r/rrrr+s
z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r/�datarrr�_process_self_data�sz(BaseSelectorEventLoop._process_self_datacCs_xXy*|jjd�}|sP|j|�Wqtk
rDwYqtk
rVPYqXqWdS)Ni)rG�recvrO�InterruptedError�BlockingIOError)r/rNrrrrM�s

z%BaseSelectorEventLoop._read_from_selfcCs[|j}|dk	rWy|jd�Wn.tk
rV|jrRtjddd�YnXdS)Nsz3Fail to write a null byte into the self-pipe socket�exc_infoT)rI�send�OSError�_debugr
r')r/Zcsockrrr�_write_to_self�s	
	z$BaseSelectorEventLoop._write_to_self�dcCs,|j|j�|j|||||�dS)N)rLrH�_accept_connection)r/�protocol_factoryr"r:r1�backlogrrr�_start_serving�sz$BaseSelectorEventLoop._start_servingcCs[xTt|�D]F}yB|j�\}}|jrGtjd|||�|jd�Wn�tttfk
rvdSYq
t	k
r}	z�|	j
t
jt
jt
j
t
jfkr	|jddd|	d|i�|j|j��|jtj|j|||||�n�WYdd}	~	Xq
Xd|i}
|j|||
||�}|j|�q
WdS)Nz#%r got a new connection from %r: %rF�messagez&socket.accept() out of system resource�	exceptionr�peername)�range�acceptrVr
r'rKrRrQ�ConnectionAbortedErrorrU�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerrFrHZ
call_laterrZACCEPT_RETRY_DELAYr\�_accept_connection2Zcreate_task)r/rZr"r:r1r[�_�conn�addr�excr0rarrrrY�s4		


z(BaseSelectorEventLoop._accept_connectionccs$d}d}y�|�}|j�}|rZ|j|||d|ddd|d|�}n$|j||d|d|d|�}y
|EdHWn|j��YnXWnytk
r}	zY|jr
ddd|	i}
|dk	r�||
d	<|dk	r||
d
<|j|
�WYdd}	~	XnXdS)Nr4r6Tr0r1r]z3Error on transport creation for incoming connectionr^r3�	transport)�
create_futurer;r5rC�	ExceptionrVrd)r/rZrgr0r:r1r3rjr4ri�contextrrrre�s4		

	

z)BaseSelectorEventLoop._accept_connection2cCsNy|j|}Wntk
r%Yn%X|j�sJtdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r.r�
is_closingr@�format)r/rrjrrr�_ensure_fd_no_transport�s
z-BaseSelectorEventLoop._ensure_fd_no_transportc	
Gs�|j�tj|||�}y|jj|�}Wn1tk
rh|jj|tj|df�YnSX|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)�
_check_closedr�Handler*rr�registerr	�
EVENT_READrN�modify�cancel)	r/r�callback�args�handler�mask�reader�writerrrrrLs


z!BaseSelectorEventLoop._add_readerc
Cs�|j�rdSy|jj|�}Wntk
r>dSYn{X|j|j}\}}|tjM}|s|jj|�n|jj	||d|f�|dk	r�|j
�dSdSdS)NFT)rAr*rrrrNr	rt�
unregisterrurv)r/rrrzr{r|rrrrFs
	
z$BaseSelectorEventLoop._remove_readerc	
Gs�|j�tj|||�}y|jj|�}Wn1tk
rh|jj|tjd|f�YnSX|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)rqrrrr*rrrsr	�EVENT_WRITErNrurv)	r/rrwrxryrrzr{r|rrr�_add_writer(s


z!BaseSelectorEventLoop._add_writerc
Cs�|j�rdSy|jj|�}Wntk
r>dSYn{X|j|j}\}}|tjM}|s|jj|�n|jj	|||df�|dk	r�|j
�dSdSdS)NFT)rAr*rrrrNr	r~r}rurv)r/rrrzr{r|rrr�_remove_writer7s
	
z$BaseSelectorEventLoop._remove_writercGs |j|�|j|||�S)N)rprL)r/rrwrxrrr�
add_readerNs
z BaseSelectorEventLoop.add_readercCs|j|�|j|�S)N)rprF)r/rrrr�
remove_readerSs
z#BaseSelectorEventLoop.remove_readercGs |j|�|j|||�S)N)rpr)r/rrwrxrrr�
add_writerXs
z BaseSelectorEventLoop.add_writercCs|j|�|j|�S)N)rpr�)r/rrrr�
remove_writer]s
z#BaseSelectorEventLoop.remove_writercCsM|jr'|j�dkr'td��|j�}|j|d||�|S)Nrzthe socket must be non-blockingF)rV�
gettimeout�
ValueErrorrk�
_sock_recv)r/r"�n�futrrr�	sock_recvbs
	zBaseSelectorEventLoop.sock_recvcCs�|j�}|r|j|�|j�r/dSy|j|�}Wnhttfk
r{|j||j|d||�Yn?tk
r�}z|j	|�WYdd}~XnX|j
|�dS)NT)rHr��	cancelledrPrRrQr�r�rl�
set_exception�
set_result)r/r��
registeredr"r�rrNrirrrr�qs
# z BaseSelectorEventLoop._sock_recvcCsc|jr'|j�dkr'td��|j�}|rR|j|d||�n
|jd�|S)Nrzthe socket must be non-blockingF)rVr�r�rk�
_sock_sendallr�)r/r"rNr�rrr�sock_sendall�s
z"BaseSelectorEventLoop.sock_sendallcCs�|j�}|r|j|�|j�r/dSy|j|�}WnSttfk
rbd}Yn6tk
r�}z|j|�dSWYdd}~XnX|t|�kr�|j	d�n5|r�||d�}|j
||j|d||�dS)NrT)rHr�r�rTrRrQrlr��lenr�r�r�)r/r�r�r"rNrr�rirrrr��s"


z#BaseSelectorEventLoop._sock_sendallccs�|jr'|j�dkr'td��ttd�sI|jtjkr�tj|d|jd|j	d|�}|j
�s�|EdH|j�d\}}}}}|j�}|j
|||�|EdHS)Nrzthe socket must be non-blocking�AF_UNIXrr�loop)rVr�r��hasattrrrr�rZ_ensure_resolvedr�done�resultrk�
_sock_connect)r/r"r>Zresolvedrfr�rrr�sock_connect�s"!	z"BaseSelectorEventLoop.sock_connectcCs�|j�}y|j|�Wn�ttfk
ro|jtj|j|��|j||j	|||�Yn?t
k
r�}z|j|�WYdd}~XnX|jd�dS)N)
rH�connectrRrQ�add_done_callback�	functools�partial�_sock_connect_doner��_sock_connect_cbrlr�r�)r/r�r"r>rrirrrr��s  z#BaseSelectorEventLoop._sock_connectcCs|j|�dS)N)r�)r/rr�rrrr��sz(BaseSelectorEventLoop._sock_connect_donecCs�|j�rdSy>|jtjtj�}|dkrMt|d|f��WnIttfk
rhYn?tk
r�}z|j	|�WYdd}~XnX|j
d�dS)NrzConnect call failed %s)r��
getsockoptr�
SOL_SOCKET�SO_ERRORrUrRrQrlr�r�)r/r�r"r>�errrirrrr��s z&BaseSelectorEventLoop._sock_connect_cbcCsJ|jr'|j�dkr'td��|j�}|j|d|�|S)Nrzthe socket must be non-blockingF)rVr�r�rk�_sock_accept)r/r"r�rrr�sock_accept�s

z!BaseSelectorEventLoop.sock_acceptcCs�|j�}|r|j|�|j�r/dSy#|j�\}}|jd�Wnettfk
r�|j||j|d|�YnEt	k
r�}z|j
|�WYdd}~XnX|j||f�dS)NFT)rHr�r�rarKrRrQr�r�rlr�r�)r/r�r�r"rrgr>rirrrr��s
  z"BaseSelectorEventLoop._sock_acceptcCs�x�|D]�\}}|j|j}\}}|tj@rk|dk	rk|jr^|j|�n
|j|�|tj@r|dk	r|jr�|j|�q|j|�qWdS)N)	�fileobjrNr	rtZ
_cancelledrFZ
_add_callbackr~r�)r/Z
event_listrrzr�r{r|rrr�_process_events
s	
	z%BaseSelectorEventLoop._process_eventscCs!|j|j��|j�dS)N)rFrHrC)r/r"rrr�
_stop_servingsz#BaseSelectorEventLoop._stop_serving)(r)�
__module__�__qualname__r%r5r;r8r?rCrErBr+rOrMrWr\rYrrerprLrFrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr)r(rr6sT

(#cs�eZdZdZeZdZdd�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ejr�dd�Zddd�Zdd�Zdd�Zdd�Z�S)�_SelectorTransport�iNcst�j||�||jd<|j�|jd<d|jkr~y|j�|jd<Wn"tjk
r}d|jd<YnX||_|j�|_	||_
d|_||_|j
�|_d|_d|_|jdk	r�|jj�||j|j	<dS)NrZsocknamer_TrF)r$r%�_extra�getsockname�getpeernamer�error�_sockrH�_sock_fd�	_protocol�_protocol_connected�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr.)r/r�r"r3r0r1)r(rrr%)s&
						
z_SelectorTransport.__init__cCs|jjg}|jdkr.|jd�n|jrD|jd�|jd|j�|jdk	r|jj�rt|jj	|jt
j�}|r�|jd�n
|jd�t|jj	|jt
j�}|r�d}nd}|j
�}|jd||f�d	d
j|�S)N�closed�closingzfd=%szread=pollingz	read=idle�pollingZidlezwrite=<%s, bufsize=%s>z<%s>� )r(r)r��appendr�r��_looprArr*r	rtr~�get_write_buffer_size�join)r/�infor��state�bufsizerrr�__repr__>s*	

	z_SelectorTransport.__repr__cCs|jd�dS)N)�_force_close)r/rrr�abortZsz_SelectorTransport.abortcCs
||_dS)N)r�)r/r3rrr�set_protocol]sz_SelectorTransport.set_protocolcCs|jS)N)r�)r/rrr�get_protocol`sz_SelectorTransport.get_protocolcCs|jS)N)r�)r/rrrrncsz_SelectorTransport.is_closingcCsn|jr
dSd|_|jj|j�|jsj|jd7_|jj|j�|jj|jd�dS)NTr)	r�r�rFr�r�r�r��	call_soon�_call_connection_lost)r/rrrrCfs			z_SelectorTransport.closecCs4|jdk	r0tjd|t�|jj�dS)Nzunclosed transport %r)r��warnings�warn�ResourceWarningrC)r/rrr�__del__tsz_SelectorTransport.__del__zFatal error on transportc	Csyt|tj�r=|jj�rhtjd||dd�n+|jjd|d|d|d|ji�|j	|�dS)Nz%r: %srSTr]r^rjr3)
�
isinstancerZ_FATAL_ERROR_IGNOREr��	get_debugr
r'rdr�r�)r/rir]rrr�_fatal_errorys	z_SelectorTransport._fatal_errorcCs�|jr
dS|jr6|jj�|jj|j�|js[d|_|jj|j�|jd7_|jj|j	|�dS)NTr)
r�r��clearr�r�r�r�rFr�r�)r/rirrrr��s		
		z_SelectorTransport._force_closecCsuz|jr|jj|�Wd|jj�d|_d|_d|_|j}|dk	rp|j�d|_XdS)N)r�r�Zconnection_lostr�rCr�r�Z_detach)r/rir1rrrr��s	
				
z(_SelectorTransport._call_connection_lostcCs
t|j�S)N)r�r�)r/rrrr��sz(_SelectorTransport.get_write_buffer_sizei)r)r�r��max_size�	bytearrayr�r�r%r�r�r�r�rnrCrZPY34r�r�r�r�r�rr)r(rr�s 
	r�cseZdZddd�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
�S)r2Ncs�t�j|||||�d|_d|_t|j�|jj|jj	|�|jj|jj
|j|j�|dk	r�|jjt
j|d�dS)NF)r$r%�_eof�_pausedr#r�r�r�r��connection_maderLr��_read_readyr�_set_result_unless_cancelled)r/r�r"r3r4r0r1)r(rrr%�s		
z!_SelectorSocketTransport.__init__cCsi|jrtd��|jr*td��d|_|jj|j�|jj�retjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r@r�r�rFr�r�r
r')r/rrr�
pause_reading�s			z&_SelectorSocketTransport.pause_readingcCsg|jstd��d|_|jr+dS|jj|j|j�|jj�rctj	d|�dS)Nz
Not pausedFz%r resumes reading)
r�r@r�r�rLr�r�r�r
r')r/rrr�resume_reading�s			z'_SelectorSocketTransport.resume_readingcCs�|jr
dSy|jj|j�}WnLttfk
r@Yn�tk
rt}z|j|d�WYdd}~XnnX|r�|jj	|�nT|j
j�r�tj
d|�|jj�}|r�|j
j|j�n
|j�dS)Nz$Fatal read error on socket transportz%r received EOF)r�r�rPr�rRrQrlr�r��
data_receivedr�r�r
r'�eof_receivedrFr�rC)r/rNri�	keep_openrrrr��s 	#z$_SelectorSocketTransport._read_readycCsNt|tttf�s1tdt|�j��|jrFtd��|sPdS|j	r�|j	t
jkrxtj
d�|j	d7_	dS|js0y|jj|�}WnPttfk
r�YnStk
r�}z|j|d�dSWYdd}~XnX||d�}|sdS|jj|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)r��bytesr��
memoryview�	TypeErrorrr)r�r@r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�r�rTrRrQrlr�r�rr��_write_ready�extend�_maybe_pause_protocol)r/rNr�rirrr�write�s4		
	z_SelectorSocketTransport.writecCs
|jr
dSy|jj|j�}Wnlttfk
r@Yn�tk
r�}z5|jj|j	�|jj
�|j|d�WYdd}~XnrX|r�|jd|�=|j�|js|jj|j	�|j
r�|jd�n|jr|jjtj�dS)Nz%Fatal write error on socket transport)r�r�rTr�rRrQrlr�r�r�r�r��_maybe_resume_protocolr�r�r��shutdownr�SHUT_WR)r/r�rirrrr�
s&	
#
			z%_SelectorSocketTransport._write_readycCs6|jr
dSd|_|js2|jjtj�dS)NT)r�r�r�r�rr�)r/rrr�	write_eof"s
			z"_SelectorSocketTransport.write_eofcCsdS)NTr)r/rrr�
can_write_eof)sz&_SelectorSocketTransport.can_write_eof)r)r�r�r%r�r�r�r�r�r�r�rr)r(rr2�s

#r2cs�eZdZeZddddd�fdd�Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�S)r<NFc

stdkrtd��|s0tj||�}d|ddi}
|rY|rY||
d<|j||
�}t�j|||||	�d|_||_||_	||_
d|_|jj
d|�|jj�r�tjd|�|jj�}nd}|j|�dS)Nzstdlib ssl module not availabler6Zdo_handshake_on_connectFr7r:z%r starts SSL handshake)�sslr@rZ_create_transport_contextZwrap_socketr$r%r��_server_hostname�_waiter�_sslcontextr�r��updater�r�r
r'�time�
_on_handshake)
r/r�r9r3r:r4r6r7r0r1Zwrap_kwargsZsslsock�
start_time)r(rrr%1s*

					z_SelectorSslTransport.__init__cCs^|jdkrdS|jj�sQ|dk	rA|jj|�n|jjd�d|_dS)N)r�r�r�r�)r/rirrr�_wakeup_waiterUsz$_SelectorSslTransport._wakeup_waiterc%Cs�y|jj�Wntjk
rH|jj|j|j|�dSYn�tjk
r||jj	|j|j|�dSYn�t
k
r}z�|jj�r�tj
d|dd�|jj|j�|jj|j�|jj�|j|�t|t�rdS�WYdd}~XnX|jj|j�|jj|j�|jj�}t|jd�s|jr|jjtjkrytj||j�Wnhtk
r}zH|jj�r�tj
d|dd�|jj�|j|�dSWYdd}~XnX|jjd|d|jj�d|jj�d	|j�d
|_d
|_ |jj|j|j!�d|_"|jj#|j$j%|�|jj#|j�|jj�r�|jj&�|}tj'd||d�dS)
Nz%r: SSL handshake failedrSTZcheck_hostnamez1%r: SSL handshake failed on matching the hostname�peercert�cipher�compressionZ
ssl_objectFz%r: SSL handshake took %.1f msg@�@)(r�Zdo_handshaker��SSLWantReadErrorr�rLr�r��SSLWantWriteErrorr�
BaseExceptionr�r
r�rFr�rCr�r�rlZgetpeercertr�r�r�Zverify_modeZ	CERT_NONEZmatch_hostnamer�r�r�r��_read_wants_write�_write_wants_readr�r�r�r�r�r�r')r/r�rir�Zdtrrrr�_sb

	


		



			z#_SelectorSslTransport._on_handshakecCsi|jrtd��|jr*td��d|_|jj|j�|jj�retjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r@r�r�rFr�r�r
r')r/rrrr��s			z#_SelectorSslTransport.pause_readingcCsg|jstd��d|_|jr+dS|jj|j|j�|jj�rctj	d|�dS)Nz
Not pausedFz%r resumes reading)
r�r@r�r�rLr�r�r�r
r')r/rrrr��s			z$_SelectorSslTransport.resume_readingcCsr|jr
dS|jrKd|_|j�|jrK|jj|j|j�y|jj|j	�}Wn�t
ttj
fk
r�Yn�tjk
r�d|_|jj|j�|jj|j|j�Yn�tk
r}z|j|d�WYdd}~XnmX|r|jj|�nSzE|jj�r=tjd|�|jj�}|r_tjd�Wd|j�XdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)r�r�r�r�r�rr�r�rPr�rRrQr�r�r�r�rFrlr�r�r�r�r
r'r�r�rC)r/rNrir�rrrr��s4			
		#z!_SelectorSslTransport._read_readycCs�|jr
dS|jrTd|_|j�|jp8|jsT|jj|j|j�|jrAy|j	j
|j�}Wn�ttt
jfk
r�d}Yn�t
jk
r�d}|jj|j�d|_YnYtk
r*}z9|jj|j�|jj�|j|d�dSWYdd}~XnX|rA|jd|�=|j�|js}|jj|j�|jr}|jd�dS)NFrTz"Fatal write error on SSL transport)r�r�r�r�r�r�rLr�r�r�rTrRrQr�r�r�r�r�rlr�r�r�r�)r/r�rirrrr��s8			
	



		z"_SelectorSslTransport._write_readycCs�t|tttf�s1tdt|�j��|s;dS|jrv|jtj	krct
jd�|jd7_dS|js�|j
j|j|j�|jj|�|j�dS)Nz1data argument must be a bytes-like object, not %rzsocket.send() raised exception.r)r�r�r�r�r�rr)r�rr�r
r�r�r�rr�r�r�r�)r/rNrrrr��s	
	z_SelectorSslTransport.writecCsdS)NFr)r/rrrr�sz#_SelectorSslTransport.can_write_eof)r)r�r�r�r�r%r�r�r�r�r�r�r�r�rr)r(rr<-s"
?
"#r<csgeZdZejZddd�fdd�Zdd�Zdd�Zddd	�Z	d
d�Z
�S)r=Ncs�t�j||||�||_|jj|jj|�|jj|jj|j|j	�|dk	r�|jjt
j|d�dS)N)r$r%�_addressr�r�r�r�rLr�r�rr�)r/r�r"r3r>r4r0)r(rrr%s	z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss!|]\}}t|�VqdS)N)r�)�.0rNrfrrr�	<genexpr>'szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)r/rrrr�&sz0_SelectorDatagramTransport.get_write_buffer_sizecCs�|jr
dSy|jj|j�\}}Wn�ttfk
rFYn|tk
rz}z|jj|�WYdd}~XnHt	k
r�}z|j
|d�WYdd}~XnX|jj||�dS)Nz&Fatal read error on datagram transport)r�r��recvfromr�rRrQrUr��error_receivedrlr�Zdatagram_received)r/rNrhrirrrr�)s	"#z&_SelectorDatagramTransport._read_readycCs�t|tttf�s1tdt|�j��|s;dS|jro|d|jfkrotd|jf��|j	r�|jr�|j	t
jkr�tj
d�|j	d7_	dS|js�y7|jr�|jj|�n|jj||�dSWn�ttfk
r&|jj|j|j�Ynqtk
r^}z|jj|�dSWYdd}~Xn9tk
r�}z|j|d�dSWYdd}~XnX|jjt|�|f�|j�dS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)r�r�r�r�r�rr)r�r�r�rr�r
r�r�r�rT�sendtorRrQr�rr��
_sendto_readyrUr�rrlr�r�r�)r/rNrhrirrrr7s<
			z!_SelectorDatagramTransport.sendtocCs:x�|jr�|jj�\}}y3|jr@|jj|�n|jj||�Wqttfk
r�|jj||f�PYqt	k
r�}z|j
j|�dSWYdd}~Xqtk
r�}z|j
|d�dSWYdd}~XqXqW|j�|js6|jj|j�|jr6|jd�dS)Nz'Fatal write error on datagram transport)r��popleftr�r�rTrrRrQ�
appendleftrUr�rrlr�r�r�r�r�r�r�)r/rNrhrirrrr^s*		
		z(_SelectorDatagramTransport._sendto_ready)r)r�r��collections�dequer�r%r�r�rrrr)r(rr=s	'r=)!�__all__rrcr�rr�r,r��ImportError�rrrrrr	r
rZ
coroutinesr�logr
rr�r#Z
BaseEventLooprZ_FlowControlMixinZ	Transportr�r2r<r=rrrr�<module>s>	
�����