AlkantarClanX12

Your IP : 18.225.175.230


Current Path : /opt/alt/python37/lib64/python3.7/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/asyncio/__pycache__/base_events.cpython-37.opt-2.pyc

B

YI~d��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZyddlZWnek
r�dZYnXddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZdZd
ZdZe ed�Z!dZ"e#�Z$dd�Z%dd�Z&dd�Z'd%dd�Z(dd�Z)e ed��rjdd�Z*ndd�Z*Gdd �d ej+�Z,Gd!d"�d"ej-�Z.Gd#d$�d$ej/�Z0dS)&�N�)�	constants)�
coroutines)�events)�futures)�	protocols)�sslproto)�tasks)�
transports)�logger)�
BaseEventLoop�dg�?�AF_INET6i�QcCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr	�Task�reprr�str)�handle�cb�r�8/opt/alt/python37/lib64/python3.7/asyncio/base_events.py�_format_handleEs
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeNs


rcCsLttd�std��n4y|�tjtjd�Wntk
rFtd��YnXdS)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr�OSError)�sockrrr�_set_reuseportWs

r'c		Cszttd�sdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nVt|t�rz|dkrzd}n>t|t�r�|dkr�d}n&yt	|�}Wnt
tfk
r�dSX|tjkr�tj
g}tr�|�tj�n|g}t|t�r�|�d�}d|k�rdSxp|D]h}yJt�||�t�rD|tjk�rD|||d||||ffS|||d||ffSWntk
�rnYnX�q
WdS)N�	inet_ptonr��Zidna�%)r r!�IPPROTO_TCPZIPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAMr�bytesr�int�	TypeErrorr"�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder(r%)	�host�port�family�type�protoZflowinfoZscopeidZafs�afrrr�_ipaddr_infobsL







r=cCs:|��s(|��}t|t�r(t|t�s(dSt�|���dS)N)�	cancelled�	exceptionr�
BaseException�	ExceptionrZ	_get_loop�stop)�fut�excrrr�_run_until_complete_cb�s
rE�TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|�tjtj	d�dS)Nr)
r9r!r3rr:r-r;r,r#rF)r&rrr�_set_nodelay�srGcCsdS)Nr)r&rrrrG�sc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�_SendfileFallbackProtocolcCsht|tj�std��||_|��|_|��|_|j	|_
|��|�|�|j
r^|jj
��|_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr
Z_FlowControlMixinr1�
_transportZget_protocol�_protoZ
is_reading�_should_resume_readingZ_protocol_paused�_should_resume_writing�
pause_reading�set_protocol�_loop�
create_future�_write_ready_fut)�self�transprrr�__init__�s


z"_SendfileFallbackProtocol.__init__c�s2|j��rtd��|j}|dkr$dS|IdHdS)NzConnection closed by peer)rI�
is_closing�ConnectionErrorrQ)rRrCrrr�drain�s
z_SendfileFallbackProtocol.draincCstd��dS)Nz?Invalid state: connection should have been established already.)�RuntimeError)rR�	transportrrr�connection_made�sz)_SendfileFallbackProtocol.connection_madecCs@|jdk	r0|dkr$|j�td��n|j�|�|j�|�dS)NzConnection is closed by peer)rQZ
set_exceptionrVrJ�connection_lost)rRrDrrrr[�s
z)_SendfileFallbackProtocol.connection_lostcCs |jdk	rdS|jj��|_dS)N)rQrIrOrP)rRrrr�
pause_writing�s
z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|j�d�d|_dS)NF)rQ�
set_result)rRrrr�resume_writing�s
z(_SendfileFallbackProtocol.resume_writingcCstd��dS)Nz'Invalid state: reading should be paused)rX)rR�datarrr�
data_received�sz'_SendfileFallbackProtocol.data_receivedcCstd��dS)Nz'Invalid state: reading should be paused)rX)rRrrr�eof_received�sz&_SendfileFallbackProtocol.eof_receivedc�sF|j�|j�|jr|j��|jdk	r2|j��|jrB|j��dS)N)	rIrNrJrK�resume_readingrQ�cancelrLr^)rRrrr�restore�s


z!_SendfileFallbackProtocol.restoreN)�__name__�
__module__�__qualname__rTrWrZr[r\r^r`rardrrrrrH�srHc@sxeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zdd�Z
dd�Zdd�Zdd�ZdS)�ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_	dS)NrF)
rO�_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_serving�_serving_forever_fut)rR�loop�sockets�protocol_factoryZssl_context�backlog�ssl_handshake_timeoutrrrrT�szServer.__init__cCsd|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__rers)rRrrr�__repr__szServer.__repr__cCs|jd7_dS)Nr)rj)rRrrr�_attachszServer._attachcCs.|jd8_|jdkr*|jdkr*|��dS)Nrr)rjri�_wakeup)rRrrr�_detachszServer._detachcCs0|j}d|_x|D]}|��s|�|�qWdS)N)rk�doner])rR�waiters�waiterrrrr|s

zServer._wakeupc	CsN|jr
dSd|_x8|jD].}|�|j�|j�|j||j||j|j�qWdS)NT)	rpriZlistenrmrO�_start_servingrlrnro)rRr&rrrr�s
zServer._start_servingcCs|jS)N)rO)rRrrr�get_loop#szServer.get_loopcCs|jS)N)rp)rRrrr�
is_serving&szServer.is_servingcCs|jdkrgSt|j�S)N)ri�list)rRrrrrs)s
zServer.socketscCsr|j}|dkrdSd|_x|D]}|j�|�qWd|_|jdk	r\|j��s\|j��d|_|jdkrn|��dS)NFr)	rirOZ
_stop_servingrprqr~rcrjr|)rRrsr&rrr�close/s




zServer.closec�s"|��tjd|jd�IdHdS)Nr)rr)r�r	�sleeprO)rRrrr�
start_servingBszServer.start_servingc	�s�|jdk	rtd|�d���|jdkr4td|�d���|��|j��|_zLy|jIdHWn6tjk
r�z|��|�	�IdHWd�XYnXWdd|_XdS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
rqrXrir�rOrPrZCancelledErrorr��wait_closed)rRrrr�
serve_foreverHs

zServer.serve_foreverc�s<|jdks|jdkrdS|j��}|j�|�|IdHdS)N)rirkrOrPr5)rRr�rrrr�]s

zServer.wait_closedN)rerfrgrTrzr{r}r|r�r�r��propertyrsr�r�r�r�rrrrrh�s

rhc@s*eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd�d
d
d�dd�Z	d�dd
d
d
d
dd�dd�Z
d�dd�Zd�dd�Zd�dd�Z
d�dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd
d<�d=d>�Zd
d<�d?d@�Zd
d<�dAdB�Z dCdD�Z!dEdF�Z"dGdH�Z#d
d<�dIdJ�Z$dKdL�Z%dMdN�Z&dOdP�Z'dQdQdQdQdR�dSdT�Z(d�dUdV�Z)d�ddW�dXdY�Z*dZd[�Z+d\d]�Z,d^d_�Z-d�d
dQdQdQd
d
d
d
d`�dadb�Z.d�dcdd�Z/d�ddW�dedf�Z0dgdh�Z1didj�Z2dd
d
dk�dldm�Z3d�dQdQdQe4d
d
d
dn�dodp�Z5dQe6j7dQdQdR�dqdr�Z8dsdt�Z9d�e6j:e6j;d
dud
d
d
d
ddv�	dwdx�Z<d
d
dy�dzd{�Z=d|d}�Z>d~d�Z?d�d��Z@eAjBeAjBeAjBdddQd��d�d��ZCeAjBeAjBeAjBdddQd��d�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd
S)�rcCs�d|_d|_d|_t��|_g|_d|_d|_d|_	t
�d�j|_
d|_|�t���d|_d|_d|_d|_d|_t��|_d|_dS)NrF�	monotonicg�������?)�_timer_cancelled_count�_closed�	_stopping�collections�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�timeZget_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debugrZ_is_debug_mode�slow_callback_duration�_current_handle�
_task_factory�"_coroutine_origin_tracking_enabled�&_coroutine_origin_tracking_saved_depth�weakrefZWeakSet�
_asyncgens�_asyncgens_shutdown_called)rRrrrrTgs$

zBaseEventLoop.__init__c	Cs.d|jj�d|���d|���d|���d�	S)Nrwz	 running=z closed=z debug=rx)ryre�
is_running�	is_closed�	get_debug)rRrrrrz�szBaseEventLoop.__repr__cCstj|d�S)N)rr)rZFuture)rRrrrrP�szBaseEventLoop.create_futurecCs@|��|jdkr0tj||d�}|jr<|jd=n|�||�}|S)N)rr���)�
_check_closedr�r	r�_source_traceback)rR�coroZtaskrrr�create_task�s

zBaseEventLoop.create_taskcCs"|dk	rt|�std��||_dS)Nz'task factory must be a callable or None)�callabler1r�)rR�factoryrrr�set_task_factory�s
zBaseEventLoop.set_task_factorycCs|jS)N)r�)rRrrr�get_task_factory�szBaseEventLoop.get_task_factoryN)�extra�servercCst�dS)N)�NotImplementedError)rRr&�protocolr�r�r�rrr�_make_socket_transport�sz$BaseEventLoop._make_socket_transportFT)�server_side�server_hostnamer�r�rv�call_connection_madecCst�dS)N)r�)rRZrawsockr��
sslcontextr�r�r�r�r�rvr�rrr�_make_ssl_transport�sz!BaseEventLoop._make_ssl_transportcCst�dS)N)r�)rRr&r��addressr�r�rrr�_make_datagram_transport�sz&BaseEventLoop._make_datagram_transportcCst�dS)N)r�)rR�piper�r�r�rrr�_make_read_pipe_transport�sz'BaseEventLoop._make_read_pipe_transportcCst�dS)N)r�)rRr�r�r�r�rrr�_make_write_pipe_transport�sz(BaseEventLoop._make_write_pipe_transportc	
�st�dS)N)r�)
rRr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transport�sz(BaseEventLoop._make_subprocess_transportcCst�dS)N)r�)rRrrr�_write_to_self�szBaseEventLoop._write_to_selfcCst�dS)N)r�)rR�
event_listrrr�_process_events�szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)r�rX)rRrrrr��szBaseEventLoop._check_closedcCs*|j�|�|��s&|�|j|���dS)N)r��discardr��call_soon_threadsafer��aclose)rR�agenrrr�_asyncgen_finalizer_hook�sz&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|�d�t|d�|j�|�dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call)�source)r��warnings�warn�ResourceWarningr��add)rRr�rrr�_asyncgen_firstiter_hook�s


z&BaseEventLoop._asyncgen_firstiter_hookc�s�d|_t|j�sdSt|j�}|j��tjdd�|D�d|d��IdH}x8t||�D]*\}}t|t	�rV|�
d|��||d��qVWdS)NTcSsg|]}|���qSr)r�)�.0Zagrrr�
<listcomp>�sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsrrz;an error occurred during closing of asynchronous generator )�messager?Zasyncgen)r��lenr�r��clearr	�gather�ziprrA�call_exception_handler)rRZ
closing_agens�results�resultr�rrr�shutdown_asyncgens�s



z BaseEventLoop.shutdown_asyncgenscCs(|��rtd��t��dk	r$td��dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)r�rXrZ_get_running_loop)rRrrr�_check_runnung	s
zBaseEventLoop._check_runnungc	Cs�|��|��|�|j�t��|_t��}tj	|j
|jd�z$t�
|�x|��|jrNPqNWWdd|_d|_t�
d�|�d�tj	|�XdS)N)�	firstiter�	finalizerF)r�r��_set_coroutine_origin_tracking�_debug�	threading�	get_identr��sys�get_asyncgen_hooks�set_asyncgen_hooksr�r�rZ_set_running_loop�	_run_oncer�)rRZold_agen_hooksrrr�run_forevers$





zBaseEventLoop.run_foreverc	Cs�|��|��t�|�}tj||d�}|r4d|_|�t�z<y|�	�Wn*|rp|�
�rp|��sp|���YnXWd|�
t�X|�
�s�td��|��S)N)rrFz+Event loop stopped before Future completed.)r�r�rZisfuturer	Z
ensure_futureZ_log_destroy_pendingZadd_done_callbackrEr�r~r>r?Zremove_done_callbackrXr�)rRZfutureZnew_taskrrr�run_until_complete's"
z BaseEventLoop.run_until_completecCs
d|_dS)NT)r�)rRrrrrBMszBaseEventLoop.stopcCsj|��rtd��|jrdS|jr,t�d|�d|_|j��|j��|j	}|dk	rfd|_	|j
dd�dS)Nz!Cannot close a running event loopzClose %rTF)�wait)r�rXr�r�r�debugr�r�r�r�Zshutdown)rR�executorrrrr�Us

zBaseEventLoop.closecCs|jS)N)r�)rRrrrr�kszBaseEventLoop.is_closedcCs2|��s.tjd|��t|d�|��s.|��dS)Nzunclosed event loop )r�)r�r�r�r�r�r�)rRrrr�__del__os
zBaseEventLoop.__del__cCs
|jdk	S)N)r�)rRrrrr�vszBaseEventLoop.is_runningcCst��S)N)r�r�)rRrrrr�zszBaseEventLoop.time)�contextcGs2|j|��||f|�d|i�}|jr.|jd=|S)Nr�r�)�call_atr�r�)rRZdelay�callbackr�r��timerrrr�
call_later�s
zBaseEventLoop.call_latercGsZ|��|jr"|��|�|d�t�|||||�}|jrB|jd=t�|j	|�d|_	|S)Nr�r�T)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushr�)rR�whenr�r�r�r�rrrr��szBaseEventLoop.call_atcGsB|��|jr"|��|�|d�|�|||�}|jr>|jd=|S)N�	call_soonr�)r�r�r�r��
_call_soonr�)rRr�r�r�rrrrr��s
zBaseEventLoop.call_sooncCsDt�|�st�|�r$td|�d���t|�s@td|�d|����dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZiscoroutineZiscoroutinefunctionr1r�)rRr��methodrrrr��s

zBaseEventLoop._check_callbackcCs.t�||||�}|jr|jd=|j�|�|S)Nr�)rZHandler�r�r5)rRr�r�r�rrrrr��s
zBaseEventLoop._call_sooncCs,|jdkrdSt��}||jkr(td��dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)r�r�r�rX)rRZ	thread_idrrrr��s	

zBaseEventLoop._check_threadcGsB|��|jr|�|d�|�|||�}|jr6|jd=|��|S)Nr�r�)r�r�r�r�r�r�)rRr�r�r�rrrrr��sz"BaseEventLoop.call_soon_threadsafecGsZ|��|jr|�|d�|dkr@|j}|dkr@tj��}||_tj|j|f|��|d�S)N�run_in_executor)rr)	r�r�r�r��
concurrentrZThreadPoolExecutorZwrap_futureZsubmit)rRr��funcr�rrrr��s
zBaseEventLoop.run_in_executorcCs
||_dS)N)r�)rRr�rrr�set_default_executor�sz"BaseEventLoop.set_default_executorcCs�|�d|��g}|r$|�d|���|r8|�d|���|rL|�d|���|r`|�d|���d�|�}t�d|�|��}t�||||||�}	|��|}
d|�d	|
d
d�d|	��}|
|jkr�t�|�n
t�|�|	S)
N�:zfamily=ztype=zproto=zflags=z, zGet address info %szGetting address info z took g@�@z.3fzms: )	r5�joinrr�r�r!�getaddrinfor��info)rRr7r8r9r:r;�flags�msg�t0Zaddrinfo�dtrrr�_getaddrinfo_debug�s&


z BaseEventLoop._getaddrinfo_debugr)r9r:r;rc
�s2|jr|j}ntj}|�d|||||||�IdHS)N)r�rr!rr�)rRr7r8r9r:r;rZgetaddr_funcrrrrs
zBaseEventLoop.getaddrinfoc�s|�dtj||�IdHS)N)r�r!�getnameinfo)rRZsockaddrrrrrrszBaseEventLoop.getnameinfo)�fallbackc
�s�|jr|��dkrtd��|�||||�y|�||||�IdHStjk
rj}z
|sZ�Wdd}~XYnX|�||||�IdHS)Nrzthe socket must be non-blocking)r�Z
gettimeoutr"�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)rRr&�file�offset�countr	rDrrr�
sock_sendfileszBaseEventLoop.sock_sendfilec�st�d|�d���dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination)rr)rRr&rrrrrrr,sz#BaseEventLoop._sock_sendfile_nativec

�s�|r|�|�|rt|tj�ntj}t|�}d}ztxn|rPt|||�}|dkrPPt|�d|�}|�d|j|�IdH}	|	s|P|�||d|	��IdH||	7}q4W|S|dkr�t	|d�r�|�||�XdS)Nr�seek)
r�minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearray�
memoryviewr��readintoZsock_sendallr )
rRr&rrr�	blocksize�buf�
total_sent�view�readrrrr
3s(
z%BaseEventLoop._sock_sendfile_fallbackcCs�dt|dd�krtd��|jtjks,td��|dk	rbt|t�sLtd�|���|dkrbtd�|���t|t�sztd�|���|dkr�td�|���dS)N�b�modez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r}))	rr"r:r!r-rr0r1�format)rRr&rrrrrrr
Ms&

z$BaseEventLoop._check_sendfile_params)�sslr9r;rr&�
local_addrr�rvc�s|
dk	r|std��|
dkr0|r0|s,td��|}
|dk	rD|sDtd��|dk	sV|dk	�r�|dk	rftd��|j||f|tj|||d�IdH}|s�td��|	dk	r�|j|	|tj|||d�IdH}
|
s�td��g}�x�|D�]J\}}}}}y�tj|||d�}|�d�|	dk	�r�x�|
D]r\}}}}}y|�|�PWnPtk
�r|}z0d	|�d
|j����}t|j	|�}|�
|�Wdd}~XYnX�qW|��d}w�|j�r�t
�d||�|�||�IdHWn^tk
�r�}z |dk	�r�|��|�
|�Wdd}~XYq�|dk	�r|���Yq�XPq�Wt|�dk�r:|d
�nJt|d
��t�fdd�|D���rf|d
�td�d�dd�|D�����n.|dk�r�td��|jtjk�r�td|����|j||||
|d�IdH\}}|j�r�|�d�}t
�d|||||�||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz1ssl_handshake_timeout is only meaningful with sslz8host/port and sock can not be specified at the same time)r9r:r;rrrz!getaddrinfo() returned empty list)r9r:r;Fz*error while attempting to bind on address z: zconnect %r to %rrrc3s|]}t|��kVqdS)N)r)r�rD)�modelrr�	<genexpr>�sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|�VqdS)N)r)r�rDrrrr"�sz5host and port was not specified and no sock specifiedz"A Stream Socket was expected, got )rvr!z%r connected to %s:%r: (%r, %r))r"�_ensure_resolvedr!r-r%�setblocking�bind�strerror�lower�errnor5r�r�rr��sock_connectr�r�allrrr:�_create_connection_transport�get_extra_info)rRrtr7r8rr9r;rr&r r�rv�infosZladdr_infos�
exceptionsr:Zcnamer��_ZladdrrDrrYr�r)r!r�create_connectionbs�


"




zBaseEventLoop.create_connectionc	�s�|�d�|�}|��}|rHt|t�r*dn|}	|j|||	||||d�}
n|�|||�}
y|IdHWn|
���YnX|
|fS)NF)r�r�rv)r$rPr�boolr�r�r�)rRr&rtrr�r�rvr�r�r�rYrrrr+�s 

z*BaseEventLoop._create_connection_transportc
�s�|��rtd��t|dtjj�}|tjjkr:td|����|tjjkr�y|�||||�IdHStj	k
r�}z
|sv�Wdd}~XYnX|s�td|����|�
||||�IdHS)NzTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport zHfallback is disabled and native sendfile is not supported for transport )rUrXrrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE�_sendfile_nativerr�_sendfile_fallback)rRrYrrrr	rrDrrr�sendfiles&
zBaseEventLoop.sendfilec�st�d��dS)Nz!sendfile syscall is not supported)rr)rRrSrrrrrrr2/szBaseEventLoop._sendfile_nativec
�s�|r|�|�|rt|d�nd}t|�}d}t|�}z~xx|rVt|||�}|dkrV|St|�d|�}	|�d|j|	�IdH}
|
s�|S|��IdH|�|	d|
��||
7}q8WWd|dkr�t	|d�r�|�||�|�
�IdHXdS)Ni@rr)rrrrHrr�rrW�writer rd)rRrSrrrrrrr;rrrrrr33s,
z BaseEventLoop._sendfile_fallback)r�r�rvc
�s�tdkrtd��t|tj�s*td|����t|dd�sFtd|�d���|��}tj|||||||dd�}|�	�|�
|�|�|j|�}	|�|j
�}
y|IdHWn.tk
r�|��|	��|
���YnX|jS)Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz
transport z  is not supported by start_tls())rvr�)rrXrZ
SSLContextr1rrPrZSSLProtocolrMrNr�rZrbrAr�rcZ_app_transport)rRrYr�r�r�r�rvr�Zssl_protocolZ
conmade_cbZ	resume_cbrrr�	start_tlsLs4	
zBaseEventLoop.start_tls)r9r;r�
reuse_address�
reuse_port�allow_broadcastr&c�s�|
dk	r�|
jtjkr"td|
�����s>�s>|s>|s>|s>|s>|	r~t��||||||	d�}d�dd�|��D��}td|�d���|
�d�d}
�n��s��s�|d	kr�td
��||fdff}�n ttd��r|tj	k�rx*��fD]}|dk	r�t
|t�s�td
��q�W||f��fff}n�t
��}x�d	�fd�ffD]�\}}|dk	�r,|j||tj|||d�IdH}|�sjtd��xB|D]:\}}}}}||f}||k�r�ddg||<||||<�qpW�q,W��fdd�|��D�}|�s�td��g}|tk	�r|�r�td��ntjdtdd��x|D]�\\}}\}}d}
d}
yxtj|tj|d�}
|�rJt|
�|	�rb|
�tjtjd�|
�d���r||
�|���r�|	�s�|�|
|�IdH|}
Wn^tk
�r�}z |
dk	�r�|
��|�|�Wdd}~XYn"|
dk	�r�|
���YnXP�qW|d	�|�}|��}|�|
||
|�}|j�r`��rPt �!d��||�nt �"d�||�y|IdHWn|���YnX||fS)NzA UDP Socket was expected, got )r �remote_addrr9r;rr7r8r9z, css$|]\}}|r|�d|��VqdS)�=Nr)r��k�vrrrr"�sz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zKsocket modifier keyword arguments can not be used when sock is specified. (�)Frzunexpected address family)NN�AF_UNIXzstring is expectedr)r9r:r;rrrz!getaddrinfo() returned empty listcs8g|]0\}}�r|ddks�r,|ddks||f�qS)rNrr)r��keyZ	addr_pair)r r:rrr��sz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zcThe *reuse_address* parameter has been deprecated as of 3.7.6 and is scheduled for removal in 3.11.�)�
stacklevel)r9r:r;z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))#r:r!r.r"�dictr�itemsr$r r?rrr1r��OrderedDictr#r%�_unsetr�r��DeprecationWarningr'r#r$ZSO_BROADCASTr%r)r�r5rPr�r�rrr�)rRrtr r:r9r;rr7r8r9r&ZoptsZproblemsZr_addrZaddr_pairs_infoZaddrZ
addr_infos�idxr-Zfamr/Zpror�r@r.Z
local_addressZremote_addressrDr�r�rYr)r r:r�create_datagram_endpointzs�









z&BaseEventLoop.create_datagram_endpointc
�s\|dd�\}}t|||||f|dd���}	|	dk	r<|	gS|j||||||d�IdHSdS)NrA)r9r:r;r)r=r)
rRr�r9r:r;rrrr7r8rrrrr#szBaseEventLoop._ensure_resolvedc�s8|j||f|tj||d�IdH}|s4td|�d���|S)N)r9r:rrrzgetaddrinfo(z) returned empty list)r#r!r-r%)rRr7r8r9rr-rrr�_create_server_getaddrinfosz(BaseEventLoop._create_server_getaddrinfor
)	r9rr&rurr7r8rvr�c	�s�t|t�rtd��|dk	r*|dkr*td��|dk	s<�dk	�r*|dk	rLtd��|	dkrhtjdkoftjdk}	g}
|dkr|dg}n$t|t�s�t|t	j
j�s�|g}n|}����fdd�|D�}tj
|d	�i�IdH}ttj�|��}d
}�z"�x|D�]}|\}}}}}yt�|||�}Wn6tjk
�rJ�j�rDtjd|||dd
�w�YnX|
�|�|	�rn|�tjtjd�|
�r|t|�t�r�|tjk�r�ttd��r�|�tjtj d�y|�!|�Wq�t"k
�r�}z t"|j#d||j$�%�f�d�Wdd}~XYq�Xq�Wd}Wd|�s&x|
D]}|�&��qWXn4|dk�r<td��|j'tj(k�rXtd|����|g}
x|
D]}|�)d
��qdWt*�|
||||�}|�r�|�+�tj,d�d�IdH�j�r�t�-d|�|S)Nz*ssl argument must be an SSLContext or Nonez1ssl_handshake_timeout is only meaningful with sslz8host/port and sock can not be specified at the same time�posix�cygwinr*csg|]}�j|���d��qS))r9r)rJ)r�r7)r9rr8rRrrr�Fsz/BaseEventLoop.create_server.<locals>.<listcomp>rrFz:create_server() failed to create socket.socket(%r, %r, %r)T)�exc_info�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz"A Stream Socket was expected, got r)rrz
%r is serving).rr1r1r"�os�namer��platformrr��abc�Iterabler	r��set�	itertools�chain�
from_iterabler!�errorr�r�warningr5r#r$ZSO_REUSEADDRr'r4rr rNZIPV6_V6ONLYr%r%r(r&r'r�r:r-r$rhr�r�r)rRrtr7r8r9rr&rurr7r8rvr�rsZhostsZfsr-Z	completedZresr<Zsocktyper;Z	canonnameZsa�errr�r)r9rr8rRr�
create_servers�


*



zBaseEventLoop.create_server)rrvc�sv|jtjkrtd|����|dk	r.|s.td��|j|||dd|d�IdH\}}|jrn|�d�}t�d|||�||fS)Nz"A Stream Socket was expected, got z1ssl_handshake_timeout is only meaningful with sslr*T)r�rvr!z%r handled: (%r, %r))	r:r!r-r"r+r�r,rr�)rRrtr&rrvrYr�rrr�connect_accepted_socket�s

z%BaseEventLoop.connect_accepted_socketc�sd|�}|��}|�|||�}y|IdHWn|���YnX|jr\t�d|��||�||fS)Nz Read pipe %r connected: (%r, %r))rPr�r�r�rr��fileno)rRrtr�r�r�rYrrr�connect_read_pipe�szBaseEventLoop.connect_read_pipec�sd|�}|��}|�|||�}y|IdHWn|���YnX|jr\t�d|��||�||fS)Nz!Write pipe %r connected: (%r, %r))rPr�r�r�rr�r])rRrtr�r�r�rYrrr�connect_write_pipe�sz BaseEventLoop.connect_write_pipecCs�|g}|dk	r"|�dt|����|dk	rJ|tjkrJ|�dt|����n8|dk	rf|�dt|����|dk	r�|�dt|����t�d�|��dS)Nzstdin=zstdout=stderr=zstdout=zstderr=� )r5rrrrr�r)rRrr�r�r�rrrr�_log_subprocess�szBaseEventLoop._log_subprocess)r�r�r��universal_newlinesr�r�c
�s�t|ttf�std��|r"td��|s.td��|dkr>td��|�}
d}|jrfd|}|�||||�|j|
|d||||f|	�IdH}|jr�|dk	r�t�d||�||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr/rr"r�rar�rr)
rRrt�cmdr�r�r�rbr�r�r�r��	debug_logrYrrr�subprocess_shell�s$zBaseEventLoop.subprocess_shellc�s�|rtd��|rtd��|dkr(td��|f|	}x.|D]&}t|ttf�s8tdt|�j����q8W|�}
d}|jr�d|��}|�||||�|j	|
|d||||f|
�IdH}|jr�|dk	r�t
�d||�||
fS)	Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z6program arguments must be a bytes or text string, not zexecute program Fz%s: %r)r"rrr/r1r:rer�rar�rr)rRrtZprogramr�r�r�rbr�r�r�r�Z
popen_args�argr�rdrYrrr�subprocess_exec�s,


zBaseEventLoop.subprocess_execcCs|jS)N)r�)rRrrr�get_exception_handler
sz#BaseEventLoop.get_exception_handlercCs(|dk	rt|�std|����||_dS)Nz+A callable object or None is expected, got )r�r1r�)rRZhandlerrrr�set_exception_handlersz#BaseEventLoop.set_exception_handlerc	Cs|�d�}|sd}|�d�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}x�t|�D]�}|dkr~qp||}|dkr�d�t�|��}d	}||�	�7}n2|dkr�d�t�|��}d
}||�	�7}nt
|�}|�|�d|���qpWtj
d�|�|d
�dS)Nr�z!Unhandled exception in event loopr?FZsource_tracebackZhandle_traceback>r�r?r*z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z: �
)rM)�getr:�
__traceback__r�r��sortedr�	traceback�format_list�rstriprr5rrX)	rRr�r�r?rMZ	log_linesr@�value�tbrrr�default_exception_handler#s6


z'BaseEventLoop.default_exception_handlercCs�|jdkr>y|�|�Wq�tk
r:tjddd�Yq�Xnny|�||�Wn\tk
r�}z>y|�d||d��Wn"tk
r�tjddd�YnXWdd}~XYnXdS)Nz&Exception in default exception handlerT)rMz$Unhandled error in exception handler)r�r?r�zeException in default exception handler while handling an unexpected error in custom exception handler)r�rsrArrX)rRr�rDrrrr�Us"
z$BaseEventLoop.call_exception_handlercCs|jr
dS|j�|�dS)N)�
_cancelledr�r5)rRrrrr�
_add_callback�szBaseEventLoop._add_callbackcCs|�|�|��dS)N)rur�)rRrrrr�_add_callback_signalsafe�s
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)r�r�)rRrrrr�_timer_handle_cancelled�sz%BaseEventLoop._timer_handle_cancelledc	Cs�t|j�}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|�|�q,Wt�|�||_d|_n8x6|jr�|jdjr�|jd8_t�	|j�}d|_qfWd}|j
s�|jr�d}n*|jr�|jdj}t
td||���t�}|j�r�|dk�r�|��}|j�|�}|��|}|dk�r tj}	ntj}	t|�}
|dk�rNt�|	d|d|
�nD|
�rpt�|	d|d|d|
�n"|dk�r�t�|	d|d|d�n|j�|�}|�|�|��|j}xD|j�r�|jd}|j|k�r�Pt�	|j�}d|_|j
�|��q�Wt|j
�}x�t|�D]|}
|j
��}|j�r,�q|j�r�zD||_|��}|��|��|}||jk�rvt� d	t!|�|�Wdd|_Xn|���qWd}dS)
NFrrg�?zpoll took %.3f ms: %s eventsg@�@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"r�r��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONrtr5r��heapify�heappopr�r�Z_whenr�maxr��MAXIMUM_SELECT_TIMEOUTr�Z	_selectorZselect�logging�INFO�DEBUGr�logr�r��range�popleftr�Z_runr�rYr)rRZsched_countZ
new_scheduledrZtimeoutr�rr�r�levelZneventZend_timeZntodo�irrrr��s�











zBaseEventLoop._run_oncecCsHt|�t|j�krdS|r2t��|_t�tj�nt�|j�||_dS)N)r1r�r��#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH)rR�enabledrrrr��s

z,BaseEventLoop._set_coroutine_origin_trackingcCs|jS)N)r�)rRrrrr�szBaseEventLoop.get_debugcCs ||_|��r|�|j|�dS)N)r�r�r�r�)rRr�rrrr�szBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)NN)FN)rN)NN)NN)PrerfrgrTrzrPr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rBr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r
r0r+r4r2r3r6rFrIr!r-r#rJr2Z
AI_PASSIVEr[r\r^r_rarrrergrhrirsr�rurvrwr�r�r�r�rrrrres�



		&	
	


.,
	l23cr)rr)1r�Zcollections.abc�concurrent.futuresr�r�rUr~rOr!rr�r�rnr�r�r�r�ImportErrorr*rrrrrrr	r
r�r�__all__rxryr r4r}�objectrFrrr'r=rErGZProtocolrHZAbstractServerrhZAbstractEventLooprrrrr�<module>sX

		
;

Do