Your IP : 18.216.161.178


Current Path : /opt/alt/python310/lib64/python3.10/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/asyncio/__pycache__/selector_events.cpython-310.opt-1.pyc

o

6��f��@s$dZdZddlZddlZddlZddlZddlZddlZddlZzddl	Z	Wne
y1dZ	YnwddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZdd�ZGdd�dej�ZGdd�dejej�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)�	constants)�events)�futures)�	protocols)�sslproto)�
transports)�trsock)�loggercCs2z|�|�}Wn
tyYdSwt|j|@�S�NF)�get_key�KeyError�boolr)�selector�fdZevent�key�r�>/opt/alt/python310/lib64/python3.10/asyncio/selector_events.py�_test_selector_event s�rcs�eZdZdZdS�fdd�	ZdSddd�dd�Z	dSddddejd	�d
d�Z	dTdd
�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdddejfdd�Zdddejfdd�Zddejfdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�ZdSd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dSdEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+�Z,S)UrzJSelector event loop.

    See events.EventLoop for API specification.
    NcsFt���|dur
t��}t�d|jj�||_|�	�t
��|_dS)NzUsing selector: %s)
�super�__init__�	selectorsZDefaultSelectorr�debug�	__class__�__name__�	_selector�_make_self_pipe�weakrefZWeakValueDictionary�_transports)�selfr�rrrr1s
zBaseSelectorEventLoop.__init__��extra�servercC�t||||||�S�N)�_SelectorSocketTransport)r!�sock�protocol�waiterr$r%rrr�_make_socket_transport;s
�z,BaseSelectorEventLoop._make_socket_transportF)�server_side�server_hostnamer$r%�ssl_handshake_timeoutc	Cs0tj|||||||	d�}
t|||
||d�|
jS)N)r/r#)r	ZSSLProtocolr(Z_app_transport)r!Zrawsockr*�
sslcontextr+r-r.r$r%r/Zssl_protocolrrr�_make_ssl_transport@s��z)BaseSelectorEventLoop._make_ssl_transportcCr&r')�_SelectorDatagramTransport)r!r)r*�addressr+r$rrr�_make_datagram_transportMs�z.BaseSelectorEventLoop._make_datagram_transportcsP|��rtd��|��rdS|��t���|jdur&|j��d|_dSdS)Nz!Cannot close a running event loop)Z
is_running�RuntimeError�	is_closed�_close_self_piper�closer�r!r"rrr8Rs



�zBaseSelectorEventLoop.closecCsB|�|j���|j��d|_|j��d|_|jd8_dS)Nr)�_remove_reader�_ssock�filenor8�_csock�
_internal_fdsr9rrrr7]s

z&BaseSelectorEventLoop._close_self_pipecCsNt��\|_|_|j�d�|j�d�|jd7_|�|j��|j�dS)NFr)	�socketZ
socketpairr;r=�setblockingr>�_add_readerr<�_read_from_selfr9rrrres
z%BaseSelectorEventLoop._make_self_pipecCsdSr'r�r!�datarrr�_process_self_datam�z(BaseSelectorEventLoop._process_self_datacCsN	z|j�d�}|s
WdS|�|�WntyYqty%YdSwq)NTi)r;�recvrE�InterruptedError�BlockingIOErrorrCrrrrBps��z%BaseSelectorEventLoop._read_from_selfcCsR|j}|dur	dSz|�d�WdSty(|jr%tjddd�YdSYdSw)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)r=�send�OSError�_debugrr)r!Zcsockrrr�_write_to_self|s���z$BaseSelectorEventLoop._write_to_self�dc
Cs"|�|��|j||||||�dSr')rAr<�_accept_connection)r!�protocol_factoryr)r0r%�backlogr/rrr�_start_serving�s
�z$BaseSelectorEventLoop._start_servingc
Cst|�D]}}z|��\}}	|jrt�d||	|�|�d�WnOtttfy,YdSt	ym}
z6|
j
t
jt
jt
j
t
jfvrb|�d|
t�|�d��|�|���|�tj|j||||||�n�WYd}
~
qd}
~
wwd|	i}|�||||||�}|�|�qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)�message�	exceptionr?�peername)�range�acceptrOrrr@rIrH�ConnectionAbortedErrorrN�errnoZEMFILEZENFILEZENOBUFSZENOMEM�call_exception_handlerr�TransportSocketr:r<Z
call_laterrZACCEPT_RETRY_DELAYrU�_accept_connection2Zcreate_task)
r!rSr)r0r%rTr/�_�conn�addr�excr$rZrrrrR�sH�������
��z(BaseSelectorEventLoop._accept_connectionc
�s��d}d}z7|�}|��}	|r|j||||	d|||d�}n
|j|||	||d�}z	|	IdHWWdSty<|���wttfyF�ty|}
z+|jrqd|
d�}|dur]||d<|dure||d<|�|�WYd}
~
dSWYd}
~
dSd}
~
ww)NT)r+r-r$r%r/)r+r$r%z3Error on transport creation for incoming connection)rVrWr*�	transport)	�
create_futurer1r,�
BaseExceptionr8�
SystemExit�KeyboardInterruptrOr])r!rSrar$r0r%r/r*rdr+rc�contextrrrr_�sJ��������z)BaseSelectorEventLoop._accept_connection2c
Cs�|}t|t�s"zt|���}Wntttfy!td|���d�wz|j|}Wn
ty3YdSw|��sBt	d|�d|����dS)NzInvalid file object: zFile descriptor z is used by transport )
�
isinstance�intr<�AttributeError�	TypeError�
ValueErrorr r�
is_closingr5)r!rr<rdrrr�_ensure_fd_no_transport�s&
�����z-BaseSelectorEventLoop._ensure_fd_no_transportc		Gs�|��t�|||d�}z|j�|�}Wnty)|j�|tj|df�Y|Sw|j|j	}\}}|j�
||tjB||f�|durH|��|Sr')�
_check_closedr�Handlerrr�registerr�
EVENT_READrD�modify�cancel�	r!r�callback�args�handler�mask�reader�writerrrrrA��"���z!BaseSelectorEventLoop._add_readercCs�|��rdSz|j�|�}Wn
tyYdSw|j|j}\}}|tjM}|s1|j�|�n
|j�	||d|f�|durE|�
�dSdS)NFT)r6rrrrrDrrt�
unregisterrurv�r!rrr{r|r}rrrr:s �z$BaseSelectorEventLoop._remove_readerc		Gs�|��t�|||d�}z|j�|�}Wnty)|j�|tjd|f�Y|Sw|j|j	}\}}|j�
||tjB||f�|durH|��|Sr')rqrrrrrrrsr�EVENT_WRITErDrurvrwrrr�_add_writer!r~z!BaseSelectorEventLoop._add_writercCs�|��rdSz|j�|�}Wn
tyYdSw|j|j}\}}|tjM}|s1|j�|�n
|j�	|||df�|durE|�
�dSdS)�Remove a writer callback.FNT)r6rrrrrDrr�rrurvr�rrr�_remove_writer1s �z$BaseSelectorEventLoop._remove_writercG�"|�|�|j||g|�R�dS)zAdd a reader callback.N)rprA�r!rrxryrrr�
add_readerH�
z BaseSelectorEventLoop.add_readercC�|�|�|�|�S)zRemove a reader callback.)rpr:�r!rrrr�
remove_readerM�

z#BaseSelectorEventLoop.remove_readercGr�)zAdd a writer callback..N)rpr�r�rrr�
add_writerRr�z BaseSelectorEventLoop.add_writercCr�)r�)rpr�r�rrr�
remove_writerWr�z#BaseSelectorEventLoop.remove_writerc	���t�|�|jr|��dkrtd��z|�|�WSttfy$Ynw|��}|�	�}|�
|�|�||j|||�}|�
tj|j||d��|IdHS)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.
        r�the socket must be non-blocking�rzN)r�_check_ssl_socketrO�
gettimeoutrnrGrIrHrer<rprA�
_sock_recv�add_done_callback�	functools�partial�_sock_read_done)r!r)�n�futrrzrrr�	sock_recv\s"�
�
�
zBaseSelectorEventLoop.sock_recvcC�"|dus|��s|�|�dSdSr')�	cancelledr��r!rr�rzrrrr�r��z%BaseSelectorEventLoop._sock_read_donec
C�|��rdSz|�|�}Wn,ttfyYdSttfy"�ty9}z|�|�WYd}~dSd}~ww|�|�dSr')	�donerGrIrHrgrhrf�
set_exception�
set_result)r!r�r)r�rDrcrrrr�vs��z BaseSelectorEventLoop._sock_recvc	�r�)z�Receive data from the socket.

        The received data is written into *buf* (a writable buffer).
        The return value is the number of bytes written.
        rr�r�N)rr�rOr�rn�	recv_intorIrHrer<rprA�_sock_recv_intor�r�r�r�)r!r)�bufr�rrzrrr�sock_recv_into�s"�
�
�
z$BaseSelectorEventLoop.sock_recv_intoc
Cr�r')	r�r�rIrHrgrhrfr�r�)r!r�r)r��nbytesrcrrrr��s��z%BaseSelectorEventLoop._sock_recv_intoc	�s��t�|�|jr|��dkrtd��z|�|�}Wn
ttfy'd}Ynw|t|�kr0dS|�	�}|�
�}|�|�|�||j
||t|�|g�}|�tj|j||d��|IdHS)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.
        rr�Nr�)rr�rOr�rnrMrIrH�lenrer<rpr��
_sock_sendall�
memoryviewr�r�r��_sock_write_done)r!r)rDr�r�rrzrrr�sock_sendall�s*�
	�

��
z"BaseSelectorEventLoop.sock_sendallc
Cs�|��rdS|d}z|�||d��}Wn,ttfy!YdSttfy*�tyA}z|�|�WYd}~dSd}~ww||7}|t|�krS|�	d�dS||d<dS)Nr)
r�rMrIrHrgrhrfr�r�r�)r!r�r)Zview�pos�startr�rcrrrr��s$
��z#BaseSelectorEventLoop._sock_sendallc�s��t�|�|jr|��dkrtd��|jtjks"tjr;|jtj	kr;|j
||j|j|j|d�IdH}|d\}}}}}|�
�}|�|||�z|IdHWd}Sd}w)zTConnect to a remote socket at address.

        This method is a coroutine.
        rr�)�family�type�proto�loopN)rr�rOr�rnr�r?ZAF_INETZ	_HAS_IPv6ZAF_INET6Z_ensure_resolvedr�r�re�
_sock_connect)r!r)r3Zresolvedr`r�rrr�sock_connect�s$�
��
z"BaseSelectorEventLoop.sock_connectc
Cs�|��}zaz|�|�WnEttfy2|�|�|�||j|||�}|�tj	|j
||d��Yn*ttfy;�t
yQ}z|�|�WYd}~nd}~ww|�d�Wd}dSWd}dSWd}dSd}w)Nr�)r<ZconnectrIrHrpr��_sock_connect_cbr�r�r�r�rgrhrfr�r�)r!r�r)r3rrzrcrrrr��s.
�����	�z#BaseSelectorEventLoop._sock_connectcCr�r')r�r�r�rrrr�r�z&BaseSelectorEventLoop._sock_write_donec
Cs�|��rdSzUz|�tjtj�}|dkrt|d|����Wn*ttfy(Yn*tt	fy1�t
yG}z|�|�WYd}~nd}~ww|�d�Wd}dSWd}dSWd}dSd}w)NrzConnect call failed )
r�Z
getsockoptr?Z
SOL_SOCKETZSO_ERRORrNrIrHrgrhrfr�r�)r!r�r)r3�errrcrrrr�s*�����z&BaseSelectorEventLoop._sock_connect_cbc�sD�t�|�|jr|��dkrtd��|��}|�||�|IdHS)aWAccept 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.
        rr�N)rr�rOr�rnre�_sock_accept)r!r)r�rrr�sock_accept*s�

z!BaseSelectorEventLoop.sock_acceptc
Cs�|��}z
|��\}}|�d�WnFttfy7|�|�|�||j||�}|�t	j
|j||d��YdStt
fy@�tyW}z|�|�WYd}~dSd}~ww|�||f�dS)NFr�)r<rZr@rIrHrprAr�r�r�r�r�rgrhrfr�r�)r!r�r)rrar3rzrcrrrr�9s"

���z"BaseSelectorEventLoop._sock_acceptc	�s��|j|j=|��}|��|��IdHz|j|j|||dd�IdHW|��|r.|��||j|j<S|��|r?|��||j|j<w)NF)Zfallback)	r �_sock_fd�
is_reading�
pause_reading�_make_empty_waiterZ
sock_sendfile�_sock�_reset_empty_waiter�resume_reading)r!Ztransp�file�offset�countr�rrr�_sendfile_nativeJs"�
��z&BaseSelectorEventLoop._sendfile_nativecCs�|D];\}}|j|j}\}}|tj@r&|dur&|jr!|�|�n|�|�|tj@r=|dur=|jr8|�|�q|�|�qdSr')	�fileobjrDrrtZ
_cancelledr:Z
_add_callbackr�r�)r!Z
event_listrr{r�r|r}rrr�_process_eventsXs

��z%BaseSelectorEventLoop._process_eventscCs|�|���|��dSr')r:r<r8)r!r)rrr�
_stop_servingfsz#BaseSelectorEventLoop._stop_servingr'�NNN)-r�
__module__�__qualname__�__doc__rr,rZSSL_HANDSHAKE_TIMEOUTr1r4r8r7rrErBrPrUrRr_rprAr:r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr"rr+sl
���
�
�	
�.
�)

rcs�eZdZdZeZdZd�fdd�	Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
ejfdd�Zddd�Zdd�Zdd�Zdd�Zdd�Z�ZS) �_SelectorTransportiNcs�t��||�t�|�|jd<z	|��|jd<Wnty&d|jd<Ynwd|jvrEz	|��|jd<Wntj	yDd|jd<Ynw||_
|��|_d|_
|�|�||_|��|_d|_d|_|jdurm|j��||j|j<dS)Nr?ZsocknamerXFr)rrrr^�_extraZgetsocknamerNZgetpeernamer?�errorr�r<r��_protocol_connected�set_protocol�_server�_buffer_factory�_buffer�
_conn_lost�_closingZ_attachr )r!r�r)r*r$r%r"rrrws0�
�




z_SelectorTransport.__init__cCs�|jjg}|jdur|�d�n|jr|�d�|�d|j���|jdurc|j��sct|jj	|jt
j�}|r=|�d�n|�d�t|jj	|jt
j�}|rQd}nd}|�
�}|�d|�d	|�d
��d�d�|��S)
N�closed�closingzfd=zread=pollingz	read=idle�pollingZidlezwrite=<z
, bufsize=�>z<{}>� )rrr��appendr�r��_loopr6rrrrtr��get_write_buffer_size�format�join)r!�infor��state�bufsizerrr�__repr__�s.


�
�z_SelectorTransport.__repr__cCs|�d�dSr')�_force_closer9rrr�abort�sz_SelectorTransport.abortcCs||_d|_dS�NT)�	_protocolr��r!r*rrrr��s
z_SelectorTransport.set_protocolcC�|jSr')r�r9rrr�get_protocol��z_SelectorTransport.get_protocolcCr�r')r�r9rrrro�r�z_SelectorTransport.is_closingcCsX|jrdSd|_|j�|j�|js*|jd7_|j�|j�|j�|jd�dSdS�NTr)	r�r�r:r�r�r�r��	call_soon�_call_connection_lostr9rrrr8�s�z_SelectorTransport.closecCs0|jdur|d|��t|d�|j��dSdS)Nzunclosed transport )�source)r��ResourceWarningr8)r!Z_warnrrr�__del__�s
�z_SelectorTransport.__del__�Fatal error on transportcCsNt|t�r|j��rtjd||dd�n|j�||||jd��|�|�dS)Nz%r: %sTrK)rVrWrdr*)	rjrNr��	get_debugrrr]r�r�)r!rcrVrrr�_fatal_error�s

��z_SelectorTransport._fatal_errorcCsd|jrdS|jr|j��|j�|j�|js!d|_|j�|j�|jd7_|j�|j	|�dSr�)
r�r��clearr�r�r�r�r:r�r��r!rcrrrr��s
z_SelectorTransport._force_closecCs�z*|jr
|j�|�W|j��d|_d|_d|_|j}|dur)|��d|_dSdS|j��d|_d|_d|_|j}|durG|��d|_wr')r�r�Zconnection_lostr�r8r�r�Z_detach)r!rcr%rrrr��s*�

�
�z(_SelectorTransport._call_connection_lostcCs
t|j�Sr')r�r�r9rrrr���
z(_SelectorTransport.get_write_buffer_sizecGs$|jrdS|jj||g|�R�dSr')r�r�rAr�rrrrA�sz_SelectorTransport._add_reader)NN)r�)rr�r��max_size�	bytearrayr�r�rr�r�r�r�ror8�warnings�warnr�r�r�r�r�rAr�rrr"rr�ks"

r�cs�eZdZdZejjZ		d#�fdd�	Z�fdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Zdd �Zd!d"�Z�ZS)$r(TNcs�d|_t��|||||�d|_d|_d|_t�|j�|j	�
|jj|�|j	�
|j
|j|j�|dur?|j	�
tj|d�dSdSr
)�_read_ready_cbrr�_eof�_paused�
_empty_waiterrZ_set_nodelayr�r�r�r��connection_maderAr��_read_readyr�_set_result_unless_cancelled)r!r�r)r*r+r$r%r"rrrs
�
��z!_SelectorSocketTransport.__init__cs.t|tj�r|j|_n|j|_t��|�dSr')rjrZBufferedProtocol�_read_ready__get_bufferr��_read_ready__data_receivedrr�r�r"rrr�s
z%_SelectorSocketTransport.set_protocolcCs|jo|jSr')r�r�r9rrrr�sz#_SelectorSocketTransport.is_readingcCsB|js|jrdSd|_|j�|j�|j��rt�d|�dSdS)NTz%r pauses reading)r�r�r�r:r�r�rrr9rrrr�"s
�z&_SelectorSocketTransport.pause_readingcCsD|js|jsdSd|_|�|j|j�|j��r t�d|�dSdS)NFz%r resumes reading)	r�r�rAr�rr�r�rrr9rrrr�*s
�z'_SelectorSocketTransport.resume_readingcCs|��dSr')r�r9rrrr2sz$_SelectorSocketTransport._read_readyc
CsD|jrdSz|j�d�}t|�std��Wn"ttfy�ty7}z
|�|d�WYd}~dSd}~wwz|j	�
|�}Wn-ttfyLYdSttfyU�tym}z
|�|d�WYd}~dSd}~ww|sv|�
�dSz	|j�|�WdSttfy��ty�}z
|�|d�WYd}~dSd}~ww)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r�r�Z
get_bufferr�r5rgrhrfr�r�r�rIrH�_read_ready__on_eofZbuffer_updated)r!r�rcr�rrrr5sP���������z0_SelectorSocketTransport._read_ready__get_bufferc
Cs�|jrdSz	|j�|j�}Wn-ttfyYdSttfy#�ty;}z
|�	|d�WYd}~dSd}~ww|sD|�
�dSz	|j�|�WdSttfyW�tyo}z
|�	|d�WYd}~dSd}~ww)Nrz2Fatal error: protocol.data_received() call failed.)
r�r�rGr�rIrHrgrhrfr�rr�Z
data_received)r!rDrcrrrrZs4�����z3_SelectorSocketTransport._read_ready__data_receivedc
Cs�|j��rt�d|�z|j��}Wn"ttfy�ty4}z
|�	|d�WYd}~dSd}~ww|r@|j�
|j�dS|��dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)
r�r�rrr�Zeof_receivedrgrhrfr�r:r�r8)r!Z	keep_openrcrrrrss 
���z,_SelectorSocketTransport._read_ready__on_eofc
Cs(t|tttf�stdt|�j����|jrtd��|j	dur"td��|s&dS|j
r=|j
tjkr4t
�d�|j
d7_
dS|js�z|j�|�}Wn,ttfySYn,ttfy\�tyt}z
|�|d�WYd}~dSd}~ww||d�}|sdS|j�|j|j�|j�|�|��dS)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)rj�bytesr�r�rmr�rr�r5rr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�rMrIrHrgrhrfr�r�r�r��_write_ready�extend�_maybe_pause_protocol)r!rDr�rcrrr�write�sB�

��z_SelectorSocketTransport.writec
Cs*|jrdSz	|j�|j�}WnKttfyYdSttfy#�tyY}z+|j	�
|j�|j��|�
|d�|jdurN|j�|�WYd}~dSWYd}~dSd}~ww|rb|jd|�=|��|js�|j	�
|j�|jdur{|j�d�|jr�|�d�dS|jr�|j�tj�dSdSdS)Nr)r�r�rMr�rIrHrgrhrfr�r�r�r�r�rr��_maybe_resume_protocolr�r�r�r��shutdownr?�SHUT_WR)r!r�rcrrrr�s<

���
�z%_SelectorSocketTransport._write_readycCs2|js|jrdSd|_|js|j�tj�dSdSr�)r�r�r�r�rr?rr9rrr�	write_eof�s�z"_SelectorSocketTransport.write_eofcCsdSr�rr9rrr�
can_write_eof�rFz&_SelectorSocketTransport.can_write_eofcs.t��|�|jdur|j�td��dSdS)NzConnection is closed by peer)rr�rr��ConnectionErrorr�r"rrr��s
��z._SelectorSocketTransport._call_connection_lostcCs6|jdur	td��|j��|_|js|j�d�|jS)NzEmpty waiter is already set)rr5r�rer�r�r9rrrr��s
z+_SelectorSocketTransport._make_empty_waitercCs
d|_dSr')rr9rrrr��r�z,_SelectorSocketTransport._reset_empty_waiterr�)rr�r�Z_start_tls_compatiblerZ
_SendfileModeZ
TRY_NATIVEZ_sendfile_compatiblerr�r�r�r�rrrrrrrrr�r�r�r�rrr"rr(�s*�%'r(csJeZdZejZ		d�fdd�	Zdd�Zdd�Zd
dd	�Z	d
d�Z
�ZS)r2Ncsbt��||||�||_|j�|jj|�|j�|j|j|j	�|dur/|j�t
j|d�dSdSr')rr�_addressr�r�r�rrAr�rrr)r!r�r)r*r3r+r$r"rrr�s
�
��z#_SelectorDatagramTransport.__init__cCstdd�|jD��S)Ncss�|]	\}}t|�VqdSr')r�)�.0rDr`rrr�	<genexpr>�s�zC_SelectorDatagramTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�r9rrrr��sz0_SelectorDatagramTransport.get_write_buffer_sizec
Cs�|jrdSz|j�|j�\}}WnEttfyYdSty4}z
|j�|�WYd}~dSd}~wt	t
fy=�tyU}z
|�|d�WYd}~dSd}~ww|j�
||�dS)Nz&Fatal read error on datagram transport)r�r�Zrecvfromr�rIrHrNr��error_receivedrgrhrfr�Zdatagram_received�r!rDrbrcrrrr�s ���z&_SelectorDatagramTransport._read_readyc
Cs|t|tttf�stdt|�j����|sdS|jr+|d|jfvr(td|j����|j}|j	rE|jrE|j	t
jkr<t�
d�|j	d7_	dS|js�z|jdrW|j�|�WdS|j�||�WdSttfyt|j�|j|j�Yn:ty�}z
|j�|�WYd}~dSd}~wttfy��ty�}z
|�|d�WYd}~dSd}~ww|j� t|�|f�|�!�dS)Nr	z!Invalid address: must be None or r
rrX�'Fatal write error on datagram transport)"rjrr�r�rmr�rrrnr�rr
rrr�r�r�rM�sendtorIrHr�r�r��
_sendto_readyrNr�rrgrhrfr�r�rrrrrr 
sR�
�

�����z!_SelectorDatagramTransport.sendtoc
Cs|jro|j��\}}z|jdr|j�|�n|j�||�WnLttfy2|j�||f�Yn=t	yJ}z
|j
�|�WYd}~dSd}~wtt
fyS�tyk}z
|�|d�WYd}~dSd}~ww|js|��|js�|j�|j�|jr�|�d�dSdSdS)NrXr)r��popleftr�r�rMr rIrH�
appendleftrNr�rrgrhrfr�rr�r�r�r�r�rrrrr!8s>
�������z(_SelectorDatagramTransport._sendto_readyr�r')rr�r��collections�dequer�rr�rr r!r�rrr"rr2�s�

+r2)r��__all__r$r\r�rr?r�rZssl�ImportError�rrrrrr	r
r�logrrZ
BaseEventLooprZ_FlowControlMixinZ	Transportr�r(r2rrrr�<module>sH�D�o

?>