AlkantarClanX12

Your IP : 18.221.27.56


Current Path : /lib64/python3.6/asyncio/__pycache__/
Upload File :
Current File : //lib64/python3.6/asyncio/__pycache__/selector_events.cpython-36.opt-1.pyc

3


 \���
@s<dZdgZddlZddlZddlZddlZddlZddlZyddlZWne	k
r^dZYnXddl
mZddl
mZddl
m
Z
ddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
lmZddlmZdd�ZGdd�dej�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)�loggercCs6y|j|�}Wntk
r"dSXt|j|@�SdS)NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�//usr/lib64/python3.6/asyncio/selector_events.py�_test_selector_event s
rcsreZdZdZdO�fdd�	ZdPddd�dd�ZdQddddd	�d
d�Zddddd	�dd
�ZdRdd�Z�fdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdSdd �ZdTd!d"�ZedUd#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z ed?d@��Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(�Z)S)VrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsFt�j�|dkrtj�}tjd|jj�||_|j	�t
j�|_dS)NzUsing selector: %s)
�super�__init__r	ZDefaultSelectorr
�debug�	__class__�__name__�	_selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfr)rrrr1s
zBaseSelectorEventLoop.__init__)�extra�servercCst||||||�S)N)�_SelectorSocketTransport)r!�sock�protocol�waiterr"r#rrr�_make_socket_transport;s
z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer"r#c

CsNtj�s"|j||||||||d�Stj||||||�}	t|||	||d�|	jS)N)r)r*r"r#)r"r#)rZ_is_sslproto_available�_make_legacy_ssl_transportZSSLProtocolr$Z_app_transport)
r!�rawsockr&�
sslcontextr'r)r*r"r#Zssl_protocolrrr�_make_ssl_transport@s

z)BaseSelectorEventLoop._make_ssl_transportc	
Cst|||||||||�	S)N)�_SelectorSslTransport)	r!r,r&r-r'r)r*r"r#rrrr+Os
z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||�S)N)�_SelectorDatagramTransport)r!r%r&�addressr'r"rrr�_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|j�rtd��|j�rdS|j�t�j�|jdk	rH|jj�d|_dS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer)r!)rrrr6^s


zBaseSelectorEventLoop.closecCst�dS)N)�NotImplementedError)r!rrr�_socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj��|jj�d|_|jj�d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor6�_csock�
_internal_fds)r!rrrr5ls

z&BaseSelectorEventLoop._close_self_pipecCsN|j�\|_|_|jjd�|jjd�|jd7_|j|jj�|j�dS)NFr)r8r:r<�setblockingr=�_add_readerr;�_read_from_self)r!rrrrts
z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!�datarrr�_process_self_data|sz(BaseSelectorEventLoop._process_self_datacCsVxPy |jjd�}|sP|j|�Wqtk
r8wYqtk
rLPYqXqWdS)Ni)r:�recvrB�InterruptedError�BlockingIOError)r!rArrrr@sz%BaseSelectorEventLoop._read_from_selfcCsJ|j}|dk	rFy|jd�Wn(tk
rD|jr@tjddd�YnXdS)N�z3Fail to write a null byte into the self-pipe socketT)�exc_info)r<�send�OSError�_debugr
r)r!Zcsockrrr�_write_to_self�sz$BaseSelectorEventLoop._write_to_self�dcCs |j|j�|j|||||�dS)N)r?r;�_accept_connection)r!�protocol_factoryr%r-r#�backlogrrr�_start_serving�sz$BaseSelectorEventLoop._start_servingcCs�x�t|�D]�}y0|j�\}}|jr2tjd|||�|jd�Wn�tttfk
rXdSt	k
r�}	z^|	j
t
jt
jt
j
t
jfkr�|jd|	|d��|j|j��|jtj|j|||||�n�WYdd}	~	Xq
Xd|i}
|j|||
||�}|j|�q
WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exception�socket�peername)�range�acceptrJr
rr>rErD�ConnectionAbortedErrorrI�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr9r;Z
call_laterrZACCEPT_RETRY_DELAYrP�_accept_connection2Zcreate_task)r!rNr%r-r#rO�_�conn�addr�excr"rVrrrrM�s4


z(BaseSelectorEventLoop._accept_connectionccs�d}d}yj|�}|j�}|r6|j||||d||d�}n|j|||||d�}y|EdHWn|j��YnXWn\tk
r�}	z@|jr�d|	d�}
|dk	r�||
d<|dk	r�||
d<|j|
�WYdd}	~	XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr&�	transport)�
create_futurer.r(r6�	ExceptionrJrY)r!rNr\r"r-r#r&r_r'r^�contextrrrrZ�s4z)BaseSelectorEventLoop._accept_connection2cCs@y|j|}Wntk
r"YnX|j�s<tdj||���dS)Nz.File descriptor {!r} is used by transport {!r})r r�
is_closingr3�format)r!rr_rrr�_ensure_fd_no_transport�sz-BaseSelectorEventLoop._ensure_fd_no_transportc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tj|df�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)�
_check_closedr�Handlerrr�registerr	�
EVENT_READrA�modify�cancel)	r!r�callback�args�handler�mask�reader�writerrrrr?�s
z!BaseSelectorEventLoop._add_readerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	||d|f�|dk	r�|j
�dSdSdS)NFT)r4rrrrrAr	ri�
unregisterrjrk)r!rrrorprqrrrr9sz$BaseSelectorEventLoop._remove_readerc	
Gs�|j�tj|||�}y|jj|�}Wn*tk
rP|jj|tjd|f�Yn>X|j|j	}\}}|jj
||tjB||f�|dk	r�|j�dS)N)rfrrgrrrrhr	�EVENT_WRITErArjrk)	r!rrlrmrnrrorprqrrr�_add_writers
z!BaseSelectorEventLoop._add_writerc
Cs�|j�rdSy|jj|�}Wntk
r0dSX|j|j}\}}|tjM}|sb|jj|�n|jj	|||df�|dk	r�|j
�dSdSdS)zRemove a writer callback.FNT)r4rrrrrAr	rsrrrjrk)r!rrrorprqrrr�_remove_writer,sz$BaseSelectorEventLoop._remove_writercGs|j|�|j||f|��S)zAdd a reader callback.)rer?)r!rrlrmrrr�
add_readerCs
z BaseSelectorEventLoop.add_readercCs|j|�|j|�S)zRemove a reader callback.)rer9)r!rrrr�
remove_readerHs
z#BaseSelectorEventLoop.remove_readercGs|j|�|j||f|��S)zAdd a writer callback..)rert)r!rrlrmrrr�
add_writerMs
z BaseSelectorEventLoop.add_writercCs|j|�|j|�S)zRemove a writer callback.)reru)r!rrrr�
remove_writerRs
z#BaseSelectorEventLoop.remove_writercCs6|jr|j�dkrtd��|j�}|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-blockingN)rJ�
gettimeout�
ValueErrorr`�
_sock_recv)r!r%�n�futrrr�	sock_recvWs
	zBaseSelectorEventLoop.sock_recvcCs�|dk	r|j|�|j�rdSy|j|�}Wn`ttfk
rb|j�}|j||j||||�Yn6tk
r�}z|j	|�WYdd}~XnX|j
|�dS)N)rw�	cancelledrCrErDr;rvr|ra�
set_exception�
set_result)r!r~�
registered_fdr%r}rArr^rrrr|fs
z BaseSelectorEventLoop._sock_recvcCsF|jr|j�dkrtd��|j�}|r8|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-blockingN)rJrzr{r`�
_sock_sendallr�)r!r%rAr~rrr�sock_sendall{s
z"BaseSelectorEventLoop.sock_sendallcCs�|dk	r|j|�|j�rdSy|j|�}WnDttfk
rHd}Yn*tk
rp}z|j|�dSd}~XnX|t|�kr�|jd�n.|r�||d�}|j	�}|j
||j||||�dS)Nr)ryr�rHrErDrar��lenr�r;rxr�)r!r~r�r%rAr}r^rrrrr��s"

z#BaseSelectorEventLoop._sock_sendallccs�|jr|j�dkrtd��ttd�s2|jtjkrptj||j|j	|d�}|j
�sZ|EdH|j�d\}}}}}|j�}|j
|||�|EdHS)zTConnect to a remote socket at address.

        This method is a coroutine.
        rzthe socket must be non-blocking�AF_UNIX)�family�proto�loopN)rJrzr{�hasattrrSr�r�rZ_ensure_resolvedr��done�resultr`�
_sock_connect)r!r%r1Zresolvedr[r~rrr�sock_connect�s
z"BaseSelectorEventLoop.sock_connectcCs�|j�}y|j|�Wnjttfk
rV|jtj|j|��|j||j	|||�Yn6t
k
r�}z|j|�WYdd}~XnX|jd�dS)N)
r;ZconnectrErDZadd_done_callback�	functools�partial�_sock_connect_donerx�_sock_connect_cbrar�r�)r!r~r%r1rr^rrrr��sz#BaseSelectorEventLoop._sock_connectcCs|j|�dS)N)ry)r!rr~rrrr��sz(BaseSelectorEventLoop._sock_connect_donecCs�|j�rdSy,|jtjtj�}|dkr6t|d|f��WnBttfk
rPYn6tk
rz}z|j	|�WYdd}~XnX|j
d�dS)NrzConnect call failed %s)r�Z
getsockoptrSZ
SOL_SOCKETZSO_ERRORrIrErDrar�r�)r!r~r%r1�errr^rrrr��sz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|j�dkrtd��|j�}|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-blockingF)rJrzr{r`�_sock_accept)r!r%r~rrr�sock_accept�s

z!BaseSelectorEventLoop.sock_acceptcCs�|j�}|r|j|�|j�r"dSy|j�\}}|jd�WnVttfk
rh|j||j|d|�Yn:t	k
r�}z|j
|�WYdd}~XnX|j||f�dS)NFT)r;rwr�rVr>rErDrvr�rar�r�)r!r~Z
registeredr%rr\r1r^rrrr��s
z"BaseSelectorEventLoop._sock_acceptcCs�x~|D]v\}}|j|j}\}}|tj@rN|dk	rN|jrD|j|�n
|j|�|tj@r|dk	r|jrr|j|�q|j|�qWdS)N)	�fileobjrAr	riZ
_cancelledr9Z
_add_callbackrsru)r!Z
event_listrror�rprqrrr�_process_events�s
z%BaseSelectorEventLoop._process_eventscCs|j|j��|j�dS)N)r9r;r6)r!r%rrr�
_stop_servingsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r�
__module__�__qualname__�__doc__rr(r.r+r2r6r8r5rrBr@rKrPrMrrZrer?r9rtrurvrwrxryrr|r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rrr+sT



(#cs�eZdZdZeZdZd �fdd�	Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ejr`dd�Zd!dd�Zdd�Zdd�Zdd�Zdd�Z�ZS)"�_SelectorTransport�iNcs�t�j||�||jd<|j�|jd<d|jkrdy|j�|jd<Wn tjk
rbd|jd<YnX||_|j�|_	||_
d|_||_|j
�|_d|_d|_|jdk	r�|jj�||j|j	<dS)NrSZsocknamerTTrF)rr�_extraZgetsocknameZgetpeernamerS�error�_sockr;�_sock_fd�	_protocol�_protocol_connected�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr )r!r�r%r&r"r#)rrrrs&





z_SelectorTransport.__init__cCs�|jjg}|jdkr |jd�n|jr0|jd�|jd|j�|jdk	r�|jj�r�t|jj	|jt
j�}|rz|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>� )rrr��appendr�r��_loopr4rrr	rirs�get_write_buffer_size�join)r!�infor��state�bufsizerrr�__repr__2s*



z_SelectorTransport.__repr__cCs|jd�dS)N)�_force_close)r!rrr�abortNsz_SelectorTransport.abortcCs
||_dS)N)r�)r!r&rrr�set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r�)r!rrr�get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r�)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr
dSd|_|jj|j�|jsP|jd7_|jj|j�|jj|jd�dS)NTr)	r�r�r9r�r�r�ru�	call_soon�_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk	r(tjd|t|d�|jj�dS)Nzunclosed transport %r)�source)r��warnings�warn�ResourceWarningr6)r!rrr�__del__hs
z_SelectorTransport.__del__�Fatal error on transportcCsPt|tj�r*|jj�rBtjd||dd�n|jj||||jd��|j	|�dS)Nz%r: %sT)rG)rQrRr_r&)
�
isinstancerZ_FATAL_ERROR_IGNOREr��	get_debugr
rrYr�r�)r!r^rQrrr�_fatal_errorns
z_SelectorTransport._fatal_errorcCsd|jr
dS|jr(|jj�|jj|j�|jsBd|_|jj|j�|jd7_|jj|j	|�dS)NTr)
r�r��clearr�rur�r�r9r�r�)r!r^rrrr�|s
z_SelectorTransport._force_closecCsVz|jr|jj|�Wd|jj�d|_d|_d|_|j}|dk	rP|j�d|_XdS)N)r�r�Zconnection_lostr�r6r�r�Z_detach)r!r^r#rrrr��s
z(_SelectorTransport._call_connection_lostcCs
t|j�S)N)r�r�)r!rrrr��sz(_SelectorTransport.get_write_buffer_sizecGs"|jr
dS|jj||f|��dS)N)r�r�r?)r!rrlrmrrrr?�sz_SelectorTransport._add_readeri)NN)r�)rr�r��max_size�	bytearrayr�r�rr�r�r�r�rcr6rZPY34r�r�r�r�r�r?r�rr)rrr�s"

r�csVeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
�ZS)r$Ncsrt�j|||||�d|_d|_tj|j�|jj|j	j
|�|jj|j|j|j
�|dk	rn|jjtj|d�dS)NF)rr�_eof�_pausedrZ_set_nodelayr�r�r�r��connection_mader?r��_read_readyr�_set_result_unless_cancelled)r!r�r%r&r'r"r#)rrrr�s

z!_SelectorSocketTransport.__init__cCs>|js|jrdSd|_|jj|j�|jj�r:tjd|�dS)NTz%r pauses reading)r�r�r�r9r�r�r
r)r!rrr�
pause_reading�s
z&_SelectorSocketTransport.pause_readingcCsB|js|jrdSd|_|j|j|j�|jj�r>tjd|�dS)NFz%r resumes reading)	r�r�r?r�r�r�r�r
r)r!rrr�resume_reading�s
z'_SelectorSocketTransport.resume_readingcCs�|jr
dSy|jj|j�}WnDttfk
r4Yn|tk
r`}z|j|d�WYdd}~XnPX|rt|jj	|�n<|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�rCr�rErDrar�r��
data_receivedr�r�r
r�eof_receivedr9r�r6)r!rAr^�	keep_openrrrr��s 

z$_SelectorSocketTransport._read_readycCs�t|tttf�s"tdt|�j��|jr0td��|s8dS|j	rf|j	t
jkrTtj
d�|j	d7_	dS|js�y|jj|�}WnBttfk
r�Yn@tk
r�}z|j|d�dSd}~XnX||d�}|s�dS|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�	TypeError�typerr�r3r�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr
�warningr�r�rHrErDrar�r�rtr��_write_ready�extend�_maybe_pause_protocol)r!rAr}r^rrr�write�s4
z_SelectorSocketTransport.writecCs�|jr
dSy|jj|j�}Wn\ttfk
r4Yn�tk
rx}z*|jj|j	�|jj
�|j|d�WYdd}~XnTX|r�|jd|�=|j�|js�|jj|j	�|j
r�|jd�n|jr�|jjtj�dS)Nz%Fatal write error on socket transport)r�r�rHr�rErDrar�rur�r�r��_maybe_resume_protocolr�r�r��shutdownrS�SHUT_WR)r!r}r^rrrr�s&
z%_SelectorSocketTransport._write_readycCs.|js|jrdSd|_|js*|jjtj�dS)NT)r�r�r�r�r�rSr�)r!rrr�	write_eofs
z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr�
can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN)rr�r�rr�r�r�r�r�r�r�r�rr)rrr$�s#r$csdeZdZeZd�fdd�	Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)r/NFc

s�tdkrtd��|s tj||�}|dd�}
|r<|r<||
d<|j|f|
�}t�j|||||	�d|_||_||_	||_
d|_|jj
|d�|jj�r�tjd|�|jj�}nd}|j|�dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)�sslr3rZ_create_transport_contextZwrap_socketrrr��_server_hostname�_waiter�_sslcontextr�r��updater�r�r
r�time�
_on_handshake)
r!r�r,r&r-r'r)r*r"r#Zwrap_kwargsZsslsock�
start_time)rrrr(s*

z_SelectorSslTransport.__init__cCsD|jdkrdS|jj�s:|dk	r.|jj|�n|jjd�d|_dS)N)r�r�r�r�)r!r^rrr�_wakeup_waiterLs

z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jj�Wn�tjk
r8|jj|j|j|�dStjk
r`|jj	|j|j|�dSt
k
r�}z`|jj�r�tj
d|dd�|jj|j�|jj|j�|jj�|j|�t|t�r�dS�WYdd}~XnX|jj|j�|jj|j�|jj�}t|jd��s�|j�r�|jjtjk�r�ytj||j�WnRtk
�r�}z4|jj��rjtj
d|dd�|jj�|j|�dSd}~XnX|jj||jj�|jj�|jd�d|_d|_ |jj|j|j!�d|_"|jj#|j$j%|�|jj#|j�|jj��r |jj&�|}tj'd||d	�dS)
Nz%r: SSL handshake failedT)rGZcheck_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��SSLWantWriteErrorrt�
BaseExceptionr�r
r�r9rur6r�r�raZgetpeercertr�r�r�Zverify_modeZ	CERT_NONEZmatch_hostnamer�r�r�r��_read_wants_write�_write_wants_readr�r�r�r�r�r�r)r!r�r^r�Zdtrrrr�Vsb













z#_SelectorSslTransport._on_handshakecCsJ|jrtd��|jrtd��d|_|jj|j�|jj�rFtjd|�dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading)	r�r3r�r�r9r�r�r
r)r!rrrr��s
z#_SelectorSslTransport.pause_readingcCsJ|jstd��d|_|jrdS|jj|j|j�|jj�rFtj	d|�dS)Nz
Not pausedFz%r resumes reading)
r�r3r�r�r?r�r�r�r
r)r!rrrr��s
z$_SelectorSslTransport.resume_readingcCs"|jr
dS|jr6d|_|j�|jr6|jj|j|j�y|jj|j	�}Wn�t
ttj
fk
rdYn�tjk
r�d|_|jj|j�|jj|j|j�Yn�tk
r�}z|j|d�WYdd}~XnTX|r�|jj|�n@z4|jj�r�tjd|�|jj�}|�rtjd�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�rtr�r�rCr�rErDr�r�r�r�r9rar�r�r�r�r
rr�r�r6)r!rAr^r�rrrr��s4

z!_SelectorSslTransport._read_readycCs(|jr
dS|jr<d|_|j�|jp(|js<|jj|j|j�|jr�y|j	j
|j�}Wn�ttt
jfk
rtd}Ynpt
jk
r�d}|jj|j�d|_YnDtk
r�}z(|jj|j�|jj�|j|d�dSd}~XnX|r�|jd|�=|j�|j�s$|jj|j�|j�r$|jd�dS)NFrTz"Fatal write error on SSL transport)r�r�r�r�r�r�r?r�r�r�rHrErDr�r�r�rur�rar�r�r�r�)r!r}r^rrrr��s8

z"_SelectorSslTransport._write_readycCs�t|tttf�s"tdt|�j��|s*dS|jrX|jtj	krFt
jd�|jd7_dS|jsp|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�r�rr�rr�r
r�r�r�rtr�r�r�r�)r!rArrrr��s
z_SelectorSslTransport.writecCsdS)NFr)r!rrrr�sz#_SelectorSslTransport.can_write_eof)NFNNN)N)rr�r�r�r�rr�r�r�r�r�r�r�r�r�rr)rrr/$s"

?
"#r/csFeZdZejZd�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r0Ncs^t�j||||�||_|jj|jj|�|jj|j|j|j	�|dk	rZ|jjt
j|d�dS)N)rr�_addressr�r�r�r�r?r�r�rr�)r!r�r%r&r1r'r")rrrrs

z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss|]\}}t|�VqdS)N)r�)�.0rAr[rrr�	<genexpr>szC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)r!rrrr�sz0_SelectorDatagramTransport.get_write_buffer_sizecCs�|jr
dSy|jj|j�\}}Wnpttfk
r8Ynhtk
rd}z|jj|�WYdd}~Xn<t	k
r�}z|j
|d�WYdd}~XnX|jj||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rErDrIr��error_receivedrar�Zdatagram_received)r!rAr]r^rrrr� sz&_SelectorDatagramTransport._read_readycCsTt|tttf�s"tdt|�j��|s*dS|jrN|d|jfkrNtd|jf��|j	r�|jr�|j	t
jkrptj
d�|j	d7_	dS|j�s4y&|jr�|jj|�n|jj||�dSttfk
r�|jj|j|j�YnZtk
�r}z|jj|�dSd}~Xn.tk
�r2}z|j|d�dSd}~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�r�rr�r{r�rr�r
r�r�r�rH�sendtorErDr�rtr��
_sendto_readyrIr�r�rar�r�r�)r!rAr]r^rrrr�.s<
z!_SelectorDatagramTransport.sendtocCs�x�|jr�|jj�\}}y&|jr,|jj|�n|jj||�Wqttfk
rf|jj||f�PYqt	k
r�}z|j
j|�dSd}~Xqtk
r�}z|j
|d�dSd}~XqXqW|j�|js�|jj|j�|jr�|jd�dS)Nz'Fatal write error on datagram transport)r��popleftr�r�rHr�rErD�
appendleftrIr�r�rar�r�r�rur�r�r�)r!rAr]r^rrrr�Us*z(_SelectorDatagramTransport._sendto_ready)NNN)N)rr�r��collections�dequer�rr�r�r�r�r�rr)rrr0s
'r0) r��__all__r�rXr�rSr�rr��ImportError�rrrrrr	r
rZ
coroutinesr�logr
rZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r$r/r0rrrr�<module>sD
ii