Your IP : 3.15.18.73


Current Path : /opt/alt/python34/lib64/python3.4/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/asyncio/__pycache__/selector_events.cpython-34.pyc

�
j f��
@s�dZdgZddlZddlZddlZddlZddlZyddlZWnek
rudZYnXddl	m
Z
ddl	mZddl	mZddl	m
Z
dd	l	mZdd
l	mZddl	mZddl	mZdd
lmZddlmZdd�ZGdd�de
j�ZGdd�dejej�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z�Event loop using a selector and related classes.

A selector is a "notify-when-ready" multiplexer.  For a subclass which
also includes support for signal handling, see the unix_events sub-module.
�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�fdZevent�key�r�</opt/alt/python34/lib64/python3.4/asyncio/selector_events.py�_test_selector_events

	rcs�eZdZdZd�fdd�Zddddddd�Zdd	d
dddddddd
�Zd	d
dddddddd�Zddddd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zddd d!�Zddd"d#�Zeddd$d%��Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z d@dA�Z!dBdC�Z"dDdE�Z#�S)FrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsUt�j�|dkr(tj�}ntjd|jj�||_|j	�dS)NzUsing selector: %s)
�super�__init__r	ZDefaultSelectorr
�debug�	__class__�__name__�	_selector�_make_self_pipe)�selfr)rrrr0s
	zBaseSelectorEventLoop.__init__�extra�servercCst||||||�S)N)�_SelectorSocketTransport)r�sock�protocol�waiterrr rrr�_make_socket_transport9sz,BaseSelectorEventLoop._make_socket_transport�server_sideF�server_hostnamec

Cs{tj�s:|j||||d|d|d|d|�Stj||||||�}	t|||	d|d|�|	jS)Nr&r'rr )rZ_is_sslproto_available�_make_legacy_ssl_transportZSSLProtocolr!Z_app_transport)
r�rawsockr#�
sslcontextr$r&r'rr Zssl_protocolrrr�_make_ssl_transport>s

z)BaseSelectorEventLoop._make_ssl_transportc	
Cs"t|||||||||�	S)N)�_SelectorSslTransport)	rr)r#r*r$r&r'rr rrrr(Msz0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||�S)N)�_SelectorDatagramTransport)rr"r#�addressr$rrrr�_make_datagram_transportWsz.BaseSelectorEventLoop._make_datagram_transportcsn|j�rtd��n|j�r+dS|j�t�j�|jdk	rj|jj�d|_ndS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer)r)rrrr3\s


zBaseSelectorEventLoop.closecCs
t�dS)N)�NotImplementedError)rrrr�_socketpairgsz!BaseSelectorEventLoop._socketpaircCsU|j|jj��|jj�d|_|jj�d|_|jd8_dS)Nr)�
remove_reader�_ssock�filenor3�_csock�
_internal_fds)rrrrr2js
	
	z&BaseSelectorEventLoop._close_self_pipecCsg|j�\|_|_|jjd�|jjd�|jd7_|j|jj�|j�dS)NFr)r5r7r9�setblockingr:�
add_readerr8�_read_from_self)rrrrrrs
z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r�datarrr�_process_self_datazsz(BaseSelectorEventLoop._process_self_datacCsbx[y-|jjd�}|s"Pn|j|�Wqtk
rGwYqtk
rYPYqXqWdS)Ni)r7�recvr?�InterruptedError�BlockingIOError)rr>rrrr=}s

z%BaseSelectorEventLoop._read_from_selfcCsa|j}|dk	r]y|jd�Wq]tk
rY|jrUtjddd�nYq]XndS)Nsz3Fail to write a null byte into the self-pipe socket�exc_infoT)r9�send�OSError�_debugr
r)rZcsockrrr�_write_to_self�s	
	z$BaseSelectorEventLoop._write_to_selfcCs)|j|j�|j||||�dS)N)r<r8�_accept_connection)r�protocol_factoryr"r*r rrr�_start_serving�sz$BaseSelectorEventLoop._start_servingc
CsDyE|j�\}}|jr7tjd|||�n|jd�Wn�tttfk
rbYn�tk
r
}z�|j	t	j
t	jt	jt	j
fkr�|jidd6|d6|d6�|j|j��|jtj|j||||�n�WYdd}~Xn6Xi|d6}|j|||||�}	|j|	�dS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource�message�	exception�socket�peername)�acceptrFr
rr;rBrA�ConnectionAbortedErrorrE�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr6r8Z
call_laterrZACCEPT_RETRY_DELAYrJ�_accept_connection2Zcreate_task)
rrIr"r*r �conn�addr�excrrOrrrrH�s0			
z(BaseSelectorEventLoop._accept_connectionccs5d}d}y�|�}tjd|�}|r`|j|||d|ddd|d|�}n$|j||d|d|d|�}y
|DdHWn|j��YnXWn�tk
r0}	zd|jridd6|	d	6}
|dk	r�||
d
<n|dk	r||
d<n|j|
�nWYdd}	~	XnXdS)N�loopr$r&Trr z3Error on transport creation for incoming connectionrKrLr#�	transport)r�Futurer+r%r3�	ExceptionrFrR)rrIrTrr*r r#rXr$rV�contextrrrrS�s6		

	


z)BaseSelectorEventLoop._accept_connection2c	
Gs�|j�tj|||�}y|jj|�}Wn1tk
rh|jj|tj|df�YnVX|j|j	}\}}|jj
||tjB||f�|dk	r�|j�ndS)zAdd a reader callback.N)�
_check_closedr�Handlerrr�registerr	�
EVENT_READr>�modify�cancel)	rr�callback�args�handler�mask�reader�writerrrrr<�s


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)zRemove a reader callback.FNT)r1rrrrr>r	r_�
unregisterr`ra)rrrrerfrgrrrr6�s
	
z#BaseSelectorEventLoop.remove_readerc	
Gs�|j�tj|||�}y|jj|�}Wn1tk
rh|jj|tjd|f�YnVX|j|j	}\}}|jj
||tjB||f�|dk	r�|j�ndS)zAdd a writer callback..N)r\rr]rrrr^r	�EVENT_WRITEr>r`ra)	rrrbrcrdrrerfrgrrr�
add_writers


z BaseSelectorEventLoop.add_writerc
Cs�|j�rdSy|jj|�}Wntk
r>dSYn{X|j|j}\}}|tjM}|s|jj|�n|jj	|||df�|dk	r�|j
�dSdSdS)zRemove a writer callback.FNT)r1rrrrr>r	rirhr`ra)rrrrerfrgrrr�
remove_writers
	
z#BaseSelectorEventLoop.remove_writercCsV|jr*|j�dkr*td��ntjd|�}|j|d||�|S)z�Receive data from the socket.

        The return value is a bytes object representing the data received.
        The maximum amount of data to be received at once is specified by
        nbytes.

        This method is a coroutine.
        rzthe socket must be non-blockingrWF)rF�
gettimeout�
ValueErrorrrY�
_sock_recv)rr"�n�futrrr�	sock_recv2s
	zBaseSelectorEventLoop.sock_recvcCs�|j�}|r"|j|�n|j�r2dSy|j|�}Wnhttfk
r~|j||j|d||�Yn?tk
r�}z|j	|�WYdd}~XnX|j
|�dS)NT)r8r6�	cancelledr@rBrAr<rnrZ�
set_exception�
set_result)rrp�
registeredr"rorr>rVrrrrnAs# z BaseSelectorEventLoop._sock_recvcCsl|jr*|j�dkr*td��ntjd|�}|r[|j|d||�n
|jd�|S)a�Send data to the socket.

        The socket must be connected to a remote socket. This method continues
        to send data from data until either all data has been sent or an
        error occurs. None is returned on success. On error, an exception is
        raised, and there is no way to determine how much data, if any, was
        successfully processed by the receiving end of the connection.

        This method is a coroutine.
        rzthe socket must be non-blockingrWFN)rFrlrmrrY�
_sock_sendallrt)rr"r>rprrr�sock_sendallVs
z"BaseSelectorEventLoop.sock_sendallcCs�|j�}|r"|j|�n|j�r2dSy|j|�}WnSttfk
red}Yn6tk
r�}z|j|�dSWYdd}~XnX|t|�kr�|j	d�n8|r�||d�}n|j
||j|d||�dS)NrT)r8rkrrrDrBrArZrs�lenrtrjrv)rrprur"r>rrorVrrrrvjs"

z#BaseSelectorEventLoop._sock_sendallcCs�|jr*|j�dkr*td��ntjd|�}ytj||�Wn2tk
r�}z|j|�WYdd}~XnX|j|||�|S)a�Connect to a remote socket at address.

        The address must be already resolved to avoid the trap of hanging the
        entire event loop when the address requires doing a DNS lookup. For
        example, it must be an IP address, not an hostname, for AF_INET and
        AF_INET6 address families. Use getaddrinfo() to resolve the hostname
        asynchronously.

        This method is a coroutine.
        rzthe socket must be non-blockingrWN)	rFrlrmrrYrZ_check_resolved_addressrs�
_sock_connect)rr"r.rp�errrrr�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)
r8ZconnectrBrAZadd_done_callback�	functools�partial�_sock_connect_donerj�_sock_connect_cbrZrsrt)rrpr"r.rrVrrrry�s
  z#BaseSelectorEventLoop._sock_connectcCs|j|�dS)N)rk)rrrprrrr~�sz(BaseSelectorEventLoop._sock_connect_donecCs�|j�rdSyA|jtjtj�}|dkrPt|d|f��nWnIttfk
rkYn?tk
r�}z|j	|�WYdd}~XnX|j
d�dS)NrzConnect call failed %s)rrZ
getsockoptrMZ
SOL_SOCKETZSO_ERRORrErBrArZrsrt)rrpr"r.rzrVrrrr�s z&BaseSelectorEventLoop._sock_connect_cbcCsS|jr*|j�dkr*td��ntjd|�}|j|d|�|S)a|Accept a connection.

        The socket must be bound to an address and listening for connections.
        The return value is a pair (conn, address) where conn is a new socket
        object usable to send and receive data on the connection, and address
        is the address bound to the socket on the other end of the connection.

        This method is a coroutine.
        rzthe socket must be non-blockingrWF)rFrlrmrrY�_sock_accept)rr"rprrr�sock_accept�s

z!BaseSelectorEventLoop.sock_acceptcCs�|j�}|r"|j|�n|j�r2dSy#|j�\}}|jd�Wnettfk
r�|j||j|d|�YnEt	k
r�}z|j
|�WYdd}~XnX|j||f�dS)NFT)r8r6rrrOr;rBrAr<r�rZrsrt)rrprur"rrTr.rVrrrr��s  z"BaseSelectorEventLoop._sock_acceptcCs�x�|D]�\}}|j|j}\}}|tj@rn|dk	rn|jr^|j|�qn|j|�n|tj@r|dk	r|jr�|j|�q�|j|�qqWdS)N)	�fileobjr>r	r_Z
_cancelledr6Z
_add_callbackrirk)rZ
event_listrrer�rfrgrrr�_process_events�s		z%BaseSelectorEventLoop._process_eventscCs!|j|j��|j�dS)N)r6r8r3)rr"rrr�
_stop_serving�sz#BaseSelectorEventLoop._stop_serving)$r�
__module__�__qualname__�__doc__rr%r+r(r/r3r5r2rr?r=rGrJrHrrSr<r6rjrkrqrnrwrvr{ryr~rr�r�r�r�rr)rrr*sL	
!#cs�eZdZdZeZdZdd�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zej
r~dd�Znddd�Zdd�Zdd�Zdd�Z�S)�_SelectorTransport�iNcs�t�j||�||jd<|j�|jd<d|jkr�y|j�|jd<Wq�tjk
r}d|jd<Yq�Xn||_|j�|_	||_
d|_||_|j
�|_d|_d|_|jdk	r�|jj�ndS)NrMZsocknamerNTrF)rr�_extraZgetsocknameZgetpeernamerM�error�_sockr8�_sock_fd�	_protocol�_protocol_connected�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attach)rrWr"r#rr )rrrr�s$
						z_SelectorTransport.__init__cCs%|jjg}|jdkr.|jd�n|jrG|jd�n|jd|j�|jdk	r|jj�rt|jj	|jt
j�}|r�|jd�n
|jd�t|jj	|jt
j�}|r�d}nd}|j
�}|jd||f�nd	d
j|�S)N�closed�closingzfd=%szread=pollingz	read=idle�pollingZidlezwrite=<%s, bufsize=%s>z<%s>� )rrr��appendr�r��_loopr1rrr	r_ri�get_write_buffer_size�join)r�infor��state�bufsizerrr�__repr__s*	
	z_SelectorTransport.__repr__cCs|jd�dS)N)�_force_close)rrrr�abort+sz_SelectorTransport.abortcCs|jS)N)r�)rrrr�
is_closing.sz_SelectorTransport.is_closingcCs^|jr
dSd|_|jj|j�|jsZ|jd7_|jj|jd�ndS)NTr)r�r�r6r�r�r��	call_soon�_call_connection_lost)rrrrr31s			z_SelectorTransport.closecCs7|jdk	r3tjd|t�|jj�ndS)Nzunclosed transport %r)r��warnings�warn�ResourceWarningr3)rrrr�__del__>sz_SelectorTransport.__del__zFatal error on transportcCs�t|tttf�rF|jj�rutjd||dd�qun/|jji|d6|d6|d6|j	d6�|j
|�dS)Nz%r: %srCTrKrLrXr#)�
isinstance�BrokenPipeError�ConnectionResetErrorrPr��	get_debugr
rrRr�r�)rrVrKrrr�_fatal_errorCs	z_SelectorTransport._fatal_errorcCs�|jr
dS|jr9|jj�|jj|j�n|jsad|_|jj|j�n|jd7_|jj|j	|�dS)NTr)
r�r��clearr�rkr�r�r6r�r�)rrVrrrr�Rs		
		z_SelectorTransport._force_closecCs{z |jr|jj|�nWd|jj�d|_d|_d|_|j}|dk	rv|j�d|_nXdS)N)r�r�Zconnection_lostr�r3r�r�Z_detach)rrVr rrrr�^s	
				
z(_SelectorTransport._call_connection_lostcCs
t|j�S)N)rxr�)rrrrr�lsz(_SelectorTransport.get_write_buffer_sizei)rr�r��max_size�	bytearrayr�r�rr�r�r�r3rZPY34r�r�r�r�r�rr)rrr��s	r�cseZdZddd�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
�S)r!Ncs�t�j|||||�d|_d|_|jj|jj|�|jj|jj|j	|j
�|dk	r�|jjtj|d�ndS)NF)
rr�_eof�_pausedr�r�r��connection_mader<r��_read_readyr�_set_result_unless_cancelled)rrWr"r#r$rr )rrrrrs		z!_SelectorSocketTransport.__init__cCsr|jrtd��n|jr0td��nd|_|jj|j�|jj�rntjd|�ndS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r0r�r�r6r�r�r
r)rrrr�
pause_reading�s			z&_SelectorSocketTransport.pause_readingcCsm|jstd��nd|_|jr.dS|jj|j|j�|jj�ritj	d|�ndS)Nz
Not pausedFz%r resumes reading)
r�r0r�r�r<r�r�r�r
r)rrrr�resume_reading�s			z'_SelectorSocketTransport.resume_readingcCs�y|jj|j�}WnLttfk
r3Yn�tk
rg}z|j|d�WYdd}~XnqX|r�|jj|�nW|j	j
�r�tjd|�n|jj
�}|r�|j	j|j�n
|j�dS)Nz$Fatal read error on socket transportz%r received EOF)r�r@r�rBrArZr�r��
data_receivedr�r�r
r�eof_receivedr6r�r3)rr>rV�	keep_openrrrr��s#z$_SelectorSocketTransport._read_readycCsVt|tttf�s0tdt|���n|jrHtd��n|sRdS|jr�|jt	j
kr}tjd�n|jd7_dS|j
s8y|jj|�}WnPttfk
r�YnStk
r}z|j|d�dSWYdd}~XnX||d�}|sdS|jj|j|j�n|j
j|�|j�dS)Nz#data argument must be byte-ish (%r)z%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)r��bytesr��
memoryview�	TypeError�typer�r0r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�r�rDrBrArZr�r�rjr��_write_ready�extend�_maybe_pause_protocol)rr>rorVrrr�write�s4			z_SelectorSocketTransport.writecCs|jstd��y|jj|j�}Wnlttfk
rHYn�tk
r�}z5|jj|j	�|jj
�|j|d�WYdd}~Xn{X|r�|jd|�=n|j�|js|jj|j	�|j
r�|jd�q|jr|jjtj�qndS)NzData should not be emptyz%Fatal write error on socket transport)r��AssertionErrorr�rDrBrArZr�rkr�r�r��_maybe_resume_protocolr�r�r��shutdownrM�SHUT_WR)rrorVrrrr��s$
#
			z%_SelectorSocketTransport._write_readycCs9|jr
dSd|_|js5|jjtj�ndS)NT)r�r�r�r�rMr�)rrrr�	write_eof�s
			z"_SelectorSocketTransport.write_eofcCsdS)NTr)rrrr�
can_write_eof�sz&_SelectorSocketTransport.can_write_eof)rr�r�rr�r�r�r�r�r�r�rr)rrr!ps

#r!cs�eZdZeZddddd�fdd�Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�S)r,NFc

stdkrtd��n|s6tj||�}ni|d6dd6}
|rd|rd||
d<n|j||
�}t�j|||||	�d|_||_||_	||_
d|_|jj
d|�|jj�rtjd|�|jj�}nd}|j|�dS)Nzstdlib ssl module not availabler&FZdo_handshake_on_connectr'r*z%r starts SSL handshake)�sslr0rZ_create_transport_contextZwrap_socketrrr��_server_hostname�_waiter�_sslcontextr�r��updater�r�r
r�time�
_on_handshake)
rrWr)r#r*r$r&r'rr Zwrap_kwargsZsslsock�
start_time)rrrr�s,


					z_SelectorSslTransport.__init__cCsa|jdkrdS|jj�sT|dk	rA|jj|�qT|jjd�nd|_dS)N)r�rrrsrt)rrVrrr�_wakeup_waiters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�n|jj|j�|jj|j�|jj�|j|�t|t�r	dS�WYdd}~XnX|jj|j�|jj|j�|jj�}t|jd�s|jr|jjtjkrytj||j�Wqtk
r}zK|jj�r�tj
d|dd�n|jj�|j|�dSWYdd}~XqXqn|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�ndS)
Nz%r: SSL handshake failedrCTZcheck_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�r<r�r��SSLWantWriteErrorrj�
BaseExceptionr�r
r�r6rkr3r�r�rZZgetpeercert�hasattrr�r�Zverify_modeZ	CERT_NONEZmatch_hostnamer�r�r�r��_read_wants_write�_write_wants_readr�r�r�r�r�r�r)rr�rVr�Zdtrrrr�!sb

	

		


			z#_SelectorSslTransport._on_handshakecCsr|jrtd��n|jr0td��nd|_|jj|j�|jj�rntjd|�ndS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r0r�r�r6r�r�r
r)rrrrr�`s			z#_SelectorSslTransport.pause_readingcCsm|jstd��nd|_|jr.dS|jj|j|j�|jj�ritj	d|�ndS)Nz
Not pausedFz%r resumes reading)
r�r0r�r�r<r�r�r�r
r)rrrrr�ps			z$_SelectorSslTransport.resume_readingcCsq|jrDd|_|j�|jrD|jj|j|j�qDny|jj|j�}Wn�t	t
tjfk
r}Yn�tj
k
r�d|_|jj|j�|jj|j|j�Yn�tk
r�}z|j|d�WYdd}~XnsX|r|jj|�nYzK|jj�r9tjd|�n|jj�}|r^tjd�nWd|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�rjr�r�r@r�rBrAr�r�r�r�r6rZr�r�r�r�r
rr�r�r3)rr>rVr�rrrr�zs0		
		#z!_SelectorSslTransport._read_readycCs�|jrMd|_|j�|jp+|jsM|jj|j|j�qMn|jr@y|jj	|j�}Wn�t
ttj
fk
r�d}Yn�tjk
r�d}|jj|j�d|_YnYtk
r#}z9|jj|j�|jj�|j|d�dSWYdd}~XnX|r@|jd|�=q@n|j�|js�|jj|j�|jr�|jd�q�ndS)NFrTz"Fatal write error on SSL transport)r�r�r�r�r�r<r�r�r�rDrBrAr�r�r�rkr�rZr�r�r�r�)rrorVrrrr��s4		
	



		z"_SelectorSslTransport._write_readycCs�t|tttf�s0tdt|���n|s:dS|jrx|jtjkret	j
d�n|jd7_dS|js�|jj
|j|j�n|jj|�|j�dS)Nz#data argument must be byte-ish (%r)zsocket.send() raised exception.r)r�r�r�r�r�r�r�rr�r
r�r�r�rjr�r�r�r�)rr>rrrr��s		z_SelectorSslTransport.writecCsdS)NFr)rrrrr��sz#_SelectorSslTransport.can_write_eof)rr�r�r�r�rr�r�r�r�r�r�r�r�rr)rrr,�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�ndS)N)rr�_addressr�r�r�r�r<r�r�rr�)rrWr"r#r.r$r)rrrr�s	z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss!|]\}}t|�VqdS)N)rx)�.0r>�_rrr�	<genexpr>�szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)rrrrr��sz0_SelectorDatagramTransport.get_write_buffer_sizecCs�y|jj|j�\}}Wn�ttfk
r9Yn|tk
rm}z|jj|�WYdd}~XnHtk
r�}z|j	|d�WYdd}~XnX|jj
||�dS)Nz&Fatal read error on datagram transport)r�Zrecvfromr�rBrArEr��error_receivedrZr�Zdatagram_received)rr>rUrVrrrr��s"#z&_SelectorDatagramTransport._read_readycCs�t|tttf�s0tdt|���n|s:dS|jrq|d|jfkrqtd|jf��n|jr�|jr�|jt	j
kr�tjd�n|jd7_dS|j
s�y7|jr�|jj|�n|jj||�dSWq�ttfk
r+|jj|j|j�Yq�tk
rc}z|jj|�dSWYdd}~Xq�tk
r�}z|j|d�dSWYdd}~Xq�Xn|j
jt|�|f�|j�dS)Nz#data argument must be byte-ish (%r)z#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)r�r�r�r�r�r�r�rmr�rr�r
r�r�r�rD�sendtorBrAr�rjr��
_sendto_readyrEr�r�rZr�r�r�)rr>rUrVrrrr��s<			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�|js<|jj|j�|jr<|jd�q<ndS)Nz'Fatal write error on datagram transport)r��popleftr�r�rDr�rBrA�
appendleftrEr�r�rZr�r�r�rkr�r�r�)rr>rUrVrrrr�s*		
		z(_SelectorDatagramTransport._sendto_ready)rr�r��collections�dequer�rr�r�r�r�rr)rrr-�s	'r-)r��__all__r�rQr|rMr�r��ImportError�rrrrrr	r
rZ
coroutinesr�logr
rZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r!r,r-rrrr�<module>s8	
����

?>