HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/imh-python/lib/python3.9/asyncio/__pycache__/base_events.cpython-39.opt-2.pyc
a

b�hQ �@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZzddlZWney�dZYn0ddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlm Z dZ!dZ"dZ#e$ed�Z%dZ&e'�Z(dd�Z)dd�Z*dd�Z+d*dd�Z,d+dd�Z-dd�Z.e$ed ��r�d!d"�Z/nd#d"�Z/Gd$d%�d%ej0�Z1Gd&d'�d'ej2�Z3Gd(d)�d)ej4�Z5dS),�N�)�	constants)�
coroutines)�events)�
exceptions)�futures)�	protocols)�sslproto)�	staggered)�tasks)�
transports)�trsock)�logger)�
BaseEventLoop�dg�?�AF_INET6i�QcCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)�	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�4/opt/imh-python/lib/python3.9/asyncio/base_events.py�_format_handleJs
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeSs


r"cCsJttd�std��n2z|�tjtjd�WntyDtd��Yn0dS)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_reuseport\s

r,c		Cs�ttd�sdS|dtjtjhvs(|dur,dS|tjkr>tj}n|tjkrPtj}ndS|durbd}nVt|t�rz|dkrzd}n>t|t�r�|dkr�d}n&zt	|�}Wnt
tfy�YdS0|tjkr�tj
g}tr�|�tj�n|g}t|t�r�|�d�}d|v�rdS|D]r}zVt�||�t�rH|tjk�rH|||d||||ffWS|||d||ffWSWnt�yvYn0�qdS)N�	inet_ptonr��Zidna�%)r$r%�IPPROTO_TCP�IPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAMr�bytesr�int�	TypeErrorr&�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder-r))	�host�port�family�type�protoZflowinfoZscopeidZafs�afrrr�_ipaddr_infogsN
�






rCcCs�t��}|D]*}|d}||vr(g||<||�|�qt|���}g}|dkr||�|dd|d��|dd|d�=|�dd�tj�tj	|��D��|S)Nrrcss|]}|dur|VqdS�Nr)�.0�arrr�	<genexpr>�s�z(_interleave_addrinfos.<locals>.<genexpr>)
�collections�OrderedDictr;�list�values�extend�	itertools�chain�
from_iterable�zip_longest)Z	addrinfosZfirst_address_family_countZaddrinfos_by_family�addrr?Zaddrinfos_listsZ	reorderedrrr�_interleave_addrinfos�s"
��rRcCs4|��s"|��}t|ttf�r"dSt�|���dSrD)�	cancelled�	exceptionr�
SystemExit�KeyboardInterruptrZ	_get_loop�stop)�fut�excrrr�_run_until_complete_cb�s
rZ�TCP_NODELAYcCs@|jtjtjhvr<|jtjkr<|jtjkr<|�tjtj	d�dS�Nr)
r?r%r9rr@r3rAr1r'r[r*rrr�_set_nodelay�s
�
�r]cCsdSrDrr*rrrr]�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_FlowControlMixinr7�
_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}|dur$dS|IdHdS)NzConnection closed by peer)r_�
is_closing�ConnectionErrorrg)rhrXrrr�drain�s
z_SendfileFallbackProtocol.draincCstd��dS)Nz?Invalid state: connection should have been established already.��RuntimeError)rh�	transportrrr�connection_made�sz)_SendfileFallbackProtocol.connection_madecCs@|jdur0|dur$|j�td��n|j�|�|j�|�dS)NzConnection is closed by peer)rg�
set_exceptionrlr`�connection_lost)rhrYrrrrs�s
�z)_SendfileFallbackProtocol.connection_lostcCs |jdurdS|jj��|_dSrD)rgr_rerf�rhrrr�
pause_writing�s
z'_SendfileFallbackProtocol.pause_writingcCs$|jdurdS|j�d�d|_dS)NF)rg�
set_resultrtrrr�resume_writing�s
z(_SendfileFallbackProtocol.resume_writingcCstd��dS�Nz'Invalid state: reading should be pausedrn)rh�datarrr�
data_received�sz'_SendfileFallbackProtocol.data_receivedcCstd��dSrxrnrtrrr�eof_receivedsz&_SendfileFallbackProtocol.eof_receivedc�sF|j�|j�|jr|j��|jdur2|j��|jrB|j��dSrD)	r_rdr`ra�resume_readingrg�cancelrbrwrtrrr�restores


z!_SendfileFallbackProtocol.restoreN)�__name__�
__module__�__qualname__rjrmrqrsrurwrzr{r~rrrrr^�sr^c@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)
re�_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_serving�_serving_forever_fut)rh�loop�sockets�protocol_factoryZssl_context�backlog�ssl_handshake_timeoutrrrrjszServer.__init__cCsd|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__rr�rtrrr�__repr__ szServer.__repr__cCs|jd7_dSr\)r�rtrrr�_attach#szServer._attachcCs.|jd8_|jdkr*|jdur*|��dS)Nrr)r�r��_wakeuprtrrr�_detach'szServer._detachcCs,|j}d|_|D]}|��s|�|�qdSrD)r��donerv)rh�waiters�waiterrrrr�-s
zServer._wakeupc	CsJ|jr
dSd|_|jD].}|�|j�|j�|j||j||j|j�qdS�NT)	r�r��listenr�re�_start_servingr�r�r�)rhr+rrrr�4s


�zServer._start_servingcCs|jSrD)rertrrr�get_loop>szServer.get_loopcCs|jSrD)r�rtrrr�
is_servingAszServer.is_servingcCs"|jdurdStdd�|jD��S)Nrcss|]}t�|�VqdSrD)r
ZTransportSocket)rE�srrrrGHr.z!Server.sockets.<locals>.<genexpr>)r��tuplertrrrr�Ds
zServer.socketscCsn|j}|durdSd|_|D]}|j�|�qd|_|jdurX|j��sX|j��d|_|jdkrj|��dS)NFr)	r�reZ
_stop_servingr�r�r�r}r�r�)rhr�r+rrr�closeJs
�

zServer.closec�s"|��tjd|jd�IdHdS)Nr�r�)r�r�sleeprertrrr�
start_serving]szServer.start_servingc	�s�|jdurtd|�d���|jdur4td|�d���|��|j��|_zRz|jIdHWn6tjy�z|��|�	�IdHW�n�0Yn0Wd|_nd|_0dS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
r�ror�r�rerfr�CancelledErrorr��wait_closedrtrrr�
serve_forevercs 

�
zServer.serve_foreverc�s<|jdus|jdurdS|j��}|j�|�|IdHdSrD)r�r�rerfr;)rhr�rrrr�xs

zServer.wait_closedN)rr�r�rjr�r�r�r�r�r�r��propertyr�r�r�r�r�rrrrr�s


r�c@sheZdZdd�Zdd�Zdd�Zdd�d	d
�Zdd�Zd
d�Zd�ddd�dd�Z	d�ddddddd�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/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zejfd=d>�Z d?d@�Z!dAdB�Z"ddC�dDdE�Z#ddC�dFdG�Z$ddC�dHdI�Z%dJdK�Z&dLdM�Z'dNdO�Z(ddC�dPdQ�Z)dRdS�Z*dTdU�Z+dVdW�Z,dXdXdXdXdY�dZd[�Z-d�d\d]�Z.d�dd^�d_d`�Z/dadb�Z0dcdd�Z1dedf�Z2d�dgdh�Z3d�ddXdXdXdddddddi�
djdk�Z4d�dldm�Z5d�dd^�dndo�Z6dpdq�Z7drds�Z8ddddt�dudv�Z9d�dXdXdXe:ddddw�dxdy�Z;dXe<j=dXdXdY�dzd{�Z>d|d}�Z?d�e<j@e<jAdd~dddddd�	d�d��ZBddd��d�d��ZCd�d��ZDd�d��ZEd�d��ZFeGjHeGjHeGjHdddXdddd��	d�d��ZIeGjHeGjHeGjHdddXdddd��	d�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUdS)�rcCs�d|_d|_d|_t��|_g|_d|_d|_d|_	t
�d�j|_
d|_|�t���d|_d|_d|_d|_d|_t��|_d|_d|_dS)NrF�	monotonicg�������?)�_timer_cancelled_count�_closed�	_stoppingrH�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�time�get_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�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called�_executor_shutdown_calledrtrrrrj�s&

zBaseEventLoop.__init__c	Cs.d|jj�d|���d|���d|���d�	S)Nr�z	 running=z closed=z debug=r�)r�r�
is_running�	is_closed�	get_debugrtrrrr��s���zBaseEventLoop.__repr__cCstj|d�S)Nr�)r�Futurertrrrrf�szBaseEventLoop.create_futureN)�namecCsN|��|jdur2tj|||d�}|jrJ|jd=n|�||�}t�||�|S)N)r�r����)�
_check_closedr�rr�_source_tracebackZ_set_task_name)rh�coror�Ztaskrrr�create_task�s

zBaseEventLoop.create_taskcCs"|durt|�std��||_dS)Nz'task factory must be a callable or None)�callabler7r�)rh�factoryrrr�set_task_factory�s
zBaseEventLoop.set_task_factorycCs|jSrD)r�rtrrr�get_task_factory�szBaseEventLoop.get_task_factory)�extra�servercCst�dSrD��NotImplementedError)rhr+�protocolr�r�r�rrr�_make_socket_transport�sz$BaseEventLoop._make_socket_transportFT)�server_side�server_hostnamer�r�r��call_connection_madecCst�dSrDr�)rhZrawsockr��
sslcontextr�r�r�r�r�r�r�rrr�_make_ssl_transport�sz!BaseEventLoop._make_ssl_transportcCst�dSrDr�)rhr+r��addressr�r�rrr�_make_datagram_transport�sz&BaseEventLoop._make_datagram_transportcCst�dSrDr��rh�piper�r�r�rrr�_make_read_pipe_transport�sz'BaseEventLoop._make_read_pipe_transportcCst�dSrDr�r�rrr�_make_write_pipe_transport�sz(BaseEventLoop._make_write_pipe_transportc	
�st�dSrDr�)
rhr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transport�sz(BaseEventLoop._make_subprocess_transportcCst�dSrDr�rtrrr�_write_to_self�szBaseEventLoop._write_to_selfcCst�dSrDr�)rh�
event_listrrr�_process_events�szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)r�rortrrrr��szBaseEventLoop._check_closedcCs|jrtd��dS)Nz!Executor shutdown has been called)r�rortrrr�_check_default_executorsz%BaseEventLoop._check_default_executorcCs*|j�|�|��s&|�|j|���dSrD)r��discardr��call_soon_threadsafer��aclose�rh�agenrrr�_asyncgen_finalizer_hooks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��addr�rrr�_asyncgen_firstiter_hook	s
�z&BaseEventLoop._asyncgen_firstiter_hookc�s�d|_t|j�sdSt|j�}|j��tjdd�|D�d|d��IdH}t||�D]*\}}t|t	�rT|�
d|��||d��qTdS)NTcSsg|]}|���qSr)r�)rEZagrrr�
<listcomp>r.z4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsr�z;an error occurred during closing of asynchronous generator )�messagerTZasyncgen)r��lenr�rJ�clearr�gather�zipr�	Exception�call_exception_handler)rhZ
closing_agens�results�resultr�rrr�shutdown_asyncgenss&


�
��z BaseEventLoop.shutdown_asyncgensc�s\d|_|jdurdS|��}tj|j|fd�}|��z|IdHW|��n
|��0dS)NT)�targetr�)r�r�rf�	threading�Thread�_do_shutdown�start�join)rh�future�threadrrr�shutdown_default_executor,s
z'BaseEventLoop.shutdown_default_executorc
CsXz |jjdd�|�|jd�Wn2tyR}z|�|j|�WYd}~n
d}~00dS)NT��wait)r��shutdownr�rvrrr)rhr�exrrrr9s
zBaseEventLoop._do_shutdowncCs(|��rtd��t��dur$td��dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)r�rorZ_get_running_looprtrrr�_check_running@s�zBaseEventLoop._check_runningc	Cs�|��|��|�|j�t��|_t��}tj	|j
|jd�zJt�
|�|��|jrLq^qLWd|_d|_t�
d�|�d�tj	|�n,d|_d|_t�
d�|�d�tj	|�0dS)N)�	firstiter�	finalizerF)r�r�_set_coroutine_origin_tracking�_debugr�	get_identr��sys�get_asyncgen_hooks�set_asyncgen_hooksr�r�rZ_set_running_loop�	_run_oncer�)rhZold_agen_hooksrrr�run_foreverGs.
�


�

zBaseEventLoop.run_foreverc	Cs�|��|��t�|�}tj||d�}|r4d|_|�t�zFz|�	�Wn*|rp|�
�rp|��sp|���Yn0W|�
t�n|�
t�0|�
�s�td��|��S)Nr�Fz+Event loop stopped before Future completed.)r�rrZisfuturerZ
ensure_futureZ_log_destroy_pending�add_done_callbackrZrr�rSrTZremove_done_callbackror)rhrZnew_taskrrr�run_until_complete^s"

z BaseEventLoop.run_until_completecCs
d|_dSr�)r�rtrrrrW�szBaseEventLoop.stopcCsp|��rtd��|jrdS|jr,t�d|�d|_|j��|j��d|_	|j
}|durld|_
|jdd�dS)Nz!Cannot close a running event loopzClose %rTFr)r�ror�rr�debugr�r�r�r�r�r�rh�executorrrrr��s

zBaseEventLoop.closecCs|jSrD)r�rtrrrr��szBaseEventLoop.is_closedcCs0|��s,|d|��t|d�|��s,|��dS)Nzunclosed event loop r�)r�r�r�r�)rh�_warnrrr�__del__�szBaseEventLoop.__del__cCs
|jduSrD)r�rtrrrr��szBaseEventLoop.is_runningcCst��SrD)r�r�rtrrrr��szBaseEventLoop.time)�contextcGs4|j|��||g|�Rd|i�}|jr0|jd=|S)Nr$r�)�call_atr�r�)rh�delay�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�)rh�whenr'r$r�r(rrrr%�szBaseEventLoop.call_atcGsB|��|jr"|��|�|d�|�|||�}|jr>|jd=|S)N�	call_soonr�)r�rr*r+�
_call_soonr��rhr'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 )rZiscoroutineZiscoroutinefunctionr7r�)rhr'�methodrrrr+�s
�
���zBaseEventLoop._check_callbackcCs.t�||||�}|jr|jd=|j�|�|S)Nr�)r�Handler�r�r;)rhr'r�r$rrrrr0�s
zBaseEventLoop._call_sooncCs,|jdurdSt��}||jkr(td��dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)r�rrro)rhZ	thread_idrrrr*s	

�zBaseEventLoop._check_threadcGsB|��|jr|�|d�|�|||�}|jr6|jd=|��|S)Nr�r�)r�rr+r0r�r�r1rrrr�sz"BaseEventLoop.call_soon_threadsafecGsh|��|jr|�|d�|durL|j}|��|durLtjjdd�}||_tj|j	|g|�R�|d�S)N�run_in_executorZasyncio)Zthread_name_prefixr�)
r�rr+r�r��
concurrentr�ThreadPoolExecutorZwrap_future�submit)rhr!�funcr�rrrr4 s��zBaseEventLoop.run_in_executorcCs&t|tjj�st�dtd�||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9�)rr5rr6r�r��DeprecationWarningr�r rrr�set_default_executor0s�z"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=�, zGet address info %szGetting address info z took g@�@z.3fzms: )	r;r
rrr�r%�getaddrinfor��info)rhr=r>r?r@rA�flags�msg�t0�addrinfo�dtrrr�_getaddrinfo_debug9s&


z BaseEventLoop._getaddrinfo_debugr�r?r@rAr@c
�s2|jr|j}ntj}|�d|||||||�IdHSrD)rrEr%r>r4)rhr=r>r?r@rAr@Zgetaddr_funcrrrr>Qs�zBaseEventLoop.getaddrinfoc�s|�dtj||�IdHSrD)r4r%�getnameinfo)rhZsockaddrr@rrrrG[s
�zBaseEventLoop.getnameinfo)�fallbackc
�s�|jr|��dkrtd��|�||||�z|�||||�IdHWStjyn}z|sZ�WYd}~n
d}~00|�||||�IdHS)Nrzthe socket must be non-blocking)r�
gettimeoutr&�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)rhr+�file�offset�countrHrYrrr�
sock_sendfile_s��zBaseEventLoop.sock_sendfilec�st�d|�d���dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination�rrL�rhr+rNrOrPrrrrKms
�z#BaseEventLoop._sock_sendfile_nativec

�s�|r|�|�|rt|tj�ntj}t|�}d}z�|rNt|||�}|dkrNq�t|�d|�}|�d|j|�IdH}	|	szq�|�||d|	��IdH||	7}q2|W|dkr�t	|d�r�|�||�Sn&|dk�r�t	|d��r�|�||�0dS)Nr�seek)
rT�minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearray�
memoryviewr4�readintoZsock_sendallr$)
rhr+rNrOrP�	blocksize�buf�
total_sent�view�readrrrrMts6
��
��z%BaseEventLoop._sock_sendfile_fallbackcCs�dt|dd�vrtd��|jtjks,td��|durbt|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%r3rr6r7�formatrSrrrrJ�s2
��
����z$BaseEventLoop._check_sendfile_paramsc�sDg}|�|�|\}}}}}	d}
z�tj|||d�}
|
�d�|dur�|D]t\}}}}}z|
�|�Wq�WqHty�}z8d|�d|j����}
t|j|
�}|�|�WYd}~qHd}~00qH|���|�	|
|	�IdH|
WSt�y }z*|�|�|
du�r
|
�
��WYd}~n(d}~0|
du�r8|
�
��Yn0dS)N�r?r@rAFz*error while attempting to bind on address �: )r;r%�setblocking�bindr)�strerror�lower�errno�pop�sock_connectr�)rhrZ	addr_infoZlocal_addr_infosZ
my_exceptionsr?�type_rA�_r�r+�laddrrYrArrr�
_connect_sock�sB



���"


zBaseEventLoop._connect_sock)
�sslr?rAr@r+�
local_addrr�r��happy_eyeballs_delay�
interleavec
	�sj|
dur|std��|
dur0|r0|s,td��|}
|durD|sDtd��|durX|
durXd}
|dusj|du�r�|durztd���j||f|tj||�d�IdH}|s�td��|	dur܈j|	|tj||�d�IdH��s�td��nd�|
r�t||
�}g�|du�rF|D]B}z ���|��IdH}W�qtWnt�y>Y�qYn0�qn.tj���fdd	�|D�|�d
�IdH\}}}|du�rdd��D��t	��dk�r��d
�nJt
�d
��t�fdd	��D���rЈd
�td�d�
dd	��D�����n.|du�rtd��|jtjk�rtd|�����j||||
|d�IdH\}}�j�rb|�d�}t�d|||||�||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host�1ssl_handshake_timeout is only meaningful with sslr�8host/port and sock can not be specified at the same time�r?r@rAr@r��!getaddrinfo() returned empty listc3s |]}t��j�|��VqdSrD)�	functools�partialrm)rErC)r�laddr_infosrhrrrGs��z2BaseEventLoop.create_connection.<locals>.<genexpr>r�cSsg|]}|D]}|�qqSrr)rE�subrYrrrr�r.z3BaseEventLoop.create_connection.<locals>.<listcomp>rc3s|]}t|��kVqdSrD�r�rErY)�modelrrrG$r.zMultiple exceptions: {}r=css|]}t|�VqdSrDrzr{rrrrG)r.z5host and port was not specified and no sock specified�"A Stream Socket was expected, got )r�r%z%r connected to %s:%r: (%r, %r))r&�_ensure_resolvedr%r3r)rRrmr
Zstaggered_racer�r�allr`r
r@�_create_connection_transportr�get_extra_inforr)rhr�r=r>rnr?rAr@r+ror�r�rprq�infosrCrkrpr�r)rrxr|rhr�create_connection�s���
��


�
��

�
���

�zBaseEventLoop.create_connectionc	�s�|�d�|�}|��}|rHt|t�r*dn|}	|j|||	||||d�}
n|�|||�}
z|IdHWn|
���Yn0|
|fS)NF�r�r�r�)rcrfr�boolr�r�r�)rhr+r�rnr�r�r�r�r�r�rprrrr�Ds"
�z*BaseEventLoop._create_connection_transportc
�s�|��rtd��t|dtjj�}|tjjur:td|����|tjjur�z|�||||�IdHWStj	y�}z|sv�WYd}~n
d}~00|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 )rkrorrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE�_sendfile_nativerrL�_sendfile_fallback)rhrprNrOrPrHr_rYrrr�sendfile^s4������zBaseEventLoop.sendfilec�st�d��dS)Nz!sendfile syscall is not supportedrR)rhrirNrOrPrrrr��s�zBaseEventLoop._sendfile_nativec
�s||r|�|�|rt|d�nd}t|�}d}t|�}�z|r�t|||�}|dkr�|W|dkrvt|d�rv|�||�|��IdHSt|�d|�}	|�d|j|	�IdH}
|
s�|W|dkr�t|d�r�|�||�|��IdHS|�	�IdH|�
|	d|
��||
7}q8W|dk�r4t|d��r4|�||�|��IdHn4|dk�rht|d��rh|�||�|��IdH0dS)Ni@rrT)rTrUrVr^r$r~rWr4rXrm�write)rhrirNrOrPrYrZr[rAr\r]rrrr��s@
	���z BaseEventLoop._sendfile_fallbackr�c
�s�tdurtd��t|tj�s*td|����t|dd�sFtd|�d���|��}tj|||||||dd�}|�	�|�
|�|�|j|�}	|�|j
�}
z|IdHWn,ty�|��|	��|
���Yn0|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())r�r�)rnrorZ
SSLContextr7rrfr	ZSSLProtocolrcrdr/rqr|�
BaseExceptionr�r}Z_app_transport)rhrpr�r�r�r�r�r�Zssl_protocolZ
conmade_cbZ	resume_cbrrr�	start_tls�s>	��
��
zBaseEventLoop.start_tls)r?rAr@�
reuse_address�
reuse_port�allow_broadcastr+c �s�|
dur�|
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�r���fD]}|dur�t
|t�s�td
��qڈ�rx�d	dv�rxz"t
�t�
��j��r.t���WnFt�yDYn4t�yv}zt�d�|�WYd}~n
d}~00||f��fff}n�i}d	�fd�ffD]�\}}|du�r�|j||tj|||d�IdH}|�s�td��|D]:\}}}}}||f}||v�rddg||<||||<�q�q���fdd�|��D�}|�sHtd��g}|tu�rv|�rftd��ntjdtdd�|D]�\\}}\}}d}
d}
zxtj|tj|d�}
|�r�t|
�|	�r�|
�tjtjd�|
�d���r�|
�|���r|	�s|� |
|�IdH|}
Wn`t�yL}z(|
du�r.|
�!�|�"|�WYd}~n.d}~0|
du�rd|
�!��Yn0�q~�qz|d	�|�}|�#�}|�$|
||
|�}|j%�rΈ�r�t�&d��||�nt�'d�||�z|IdHWn|�!��Yn0||fS)NzA UDP Socket was expected, got )ro�remote_addrr?rAr@r�r�r�r=css$|]\}}|r|�d|��VqdS)�=Nr)rE�k�vrrrrG�r.z9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zKsocket modifier keyword arguments can not be used when sock is specified. (�)Frzunexpected address family)NN�AF_UNIXzstring is expected)r�z2Unable to check or remove stale UNIX socket %r: %rrrtrucs8g|]0\}}�r|ddus�r,|ddus||f�qS)rNrr)rE�keyZ	addr_pair�ror�rrr�s�z: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.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r9)�
stacklevelraz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r@r%r4r&�dictr
�itemsrcr$r�rrr7�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr)r�errorr~�_unsetr�r�r:r,r'r(�SO_BROADCASTrdrir�r;rfr�rr?r) rhr�ror�r?rAr@r�r�r�r+ZoptsZproblemsZr_addrZaddr_pairs_inforQ�errZ
addr_infos�idxr�ZfamrkZpror�r�rZ
local_addressZremote_addressrYr�r�rprr�r�create_datagram_endpoint�s���������

��
�
�

���
�




���z&BaseEventLoop.create_datagram_endpointc
�s^|dd�\}}t|||||g|dd��R�}	|	dur>|	gS|j||||||d�IdHSdS)Nr9rF)rCr>)
rhr�r?r@rAr@r�r=r>r?rrrr~ks �zBaseEventLoop._ensure_resolvedc�s8|j||f|tj||d�IdH}|s4td|�d���|S)N)r?r@r@r�zgetaddrinfo(z) returned empty list)r~r%r3r))rhr=r>r?r@r�rrr�_create_server_getaddrinfows�z(BaseEventLoop._create_server_getaddrinfor)	r?r@r+r�rnr�r�r�r�c	�s�t|t�rtd��|dur*|dur*td��|dus<�du�r<|durLtd��|	durhtjdkoftjdk}	g}
|dkr|dg}n$t|t�s�t|t	j
j�s�|g}n|}����fdd�|D�}tj
|d	�i�IdH}ttj�|��}d
}�z8|D�]}|\}}}}}zt�|||�}Wn6tj�yF�j�r>tjd|||dd
�Yq�Yn0|
�|�|	�rj|�tjtjd�|
�rxt|�t�r�|tjk�r�ttd��r�|�tjtj d�z|�!|�Wq�t"�y�}z(t"|j#d||j$�%�f�d�WYd}~q�d}~00q�d}W|�s:|
D]}|�&��qn|�s8|
D]}|�&��q(0n4|du�rNtd��|j'tj(k�rjtd|����|g}
|
D]}|�)d
��qtt*�|
||||�}|�r�|�+�tj,d�d�IdH�j�r�t�-d|�|S)Nz*ssl argument must be an SSLContext or Nonerrrs�posix�cygwinr/csg|]}�j|���d��qS))r?r@)r�)rEr=�r?r@r>rhrrr��s�
�z/BaseEventLoop.create_server.<locals>.<listcomp>r�Fz: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 specifiedr}rr�z
%r is serving).rr�r7r&r�r�r�platformrrH�abc�Iterablerr��setrMrNrOr%r�rr�warningr;r'r(�SO_REUSEADDRr,r:rr$r��IPV6_V6ONLYrdr)rgrerfr�r@r3rcr�r�r�r?)rhr�r=r>r?r@r+r�rnr�r�r�r�r�Zhosts�fsr�Z	completed�resrB�socktyperA�	canonname�sar�r�rr�r�
create_servers�
��
��
�


�������
�zBaseEventLoop.create_server)rnr�c�sv|jtjkrtd|����|dur.|s.td��|j|||dd|d�IdH\}}|jrn|�d�}t�d|||�||fS)Nr}rrr/T)r�r�r%z%r handled: (%r, %r))	r@r%r3r&r�rr�rr)rhr�r+rnr�rpr�rrr�connect_accepted_socket�s�
�
z%BaseEventLoop.connect_accepted_socketc�sd|�}|��}|�|||�}z|IdHWn|���Yn0|jr\t�d|��||�||fS)Nz Read pipe %r connected: (%r, %r))rfr�r�rrr�fileno�rhr�r�r�r�rprrr�connect_read_pipes
�zBaseEventLoop.connect_read_pipec�sd|�}|��}|�|||�}z|IdHWn|���Yn0|jr\t�d|��||�||fS)Nz!Write pipe %r connected: (%r, %r))rfr�r�rrrr�r�rrr�connect_write_pipe!s
�z BaseEventLoop.connect_write_pipecCs�|g}|dur"|�dt|����|durJ|tjkrJ|�dt|����n8|durf|�dt|����|dur�|�dt|����t�d�|��dS)Nzstdin=zstdout=stderr=zstdout=zstderr=� )r;r"rr rrr
)rhrAr�r�r�r?rrr�_log_subprocess1szBaseEventLoop._log_subprocess)	r�r�r��universal_newlinesr�r��encoding�errors�textc	�s�t|ttf�std��|r"td��|s.td��|dkr>td��|rJtd��|	durZtd��|
durjtd��|�}
d}|jr�d	|}|�||||�|j|
|d
||||fi|��IdH}|jr�|dur�t�d||�||
fS)Nzcmd must be a string� universal_newlines must be Falsezshell must be Truer�bufsize must be 0�text must be False�encoding must be None�errors must be Nonezrun shell command %rT�%s: %r)	rr5rr&rr�r�rr?)rhr��cmdr�r�r�r�r�r�r�r�r�r�r��	debug_logrprrr�subprocess_shell>s6��zBaseEventLoop.subprocess_shellc	�s�|rtd��|rtd��|dkr(td��|r4td��|	durDtd��|
durTtd��|f|}|�}d}|jr�d|��}|�||||�|j||d	||||fi|
��IdH}|jr�|dur�t�d
||�||fS)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r&rr�r�rr?)rhr�Zprogramr�r�r�r�r�r�r�r�r�r�r�Z
popen_argsr�r�rprrr�subprocess_execbs6

��zBaseEventLoop.subprocess_execcCs|jSrD)r�rtrrr�get_exception_handler�sz#BaseEventLoop.get_exception_handlercCs(|durt|�std|����||_dS)Nz+A callable object or None is expected, got )r�r7r�)rh�handlerrrr�set_exception_handler�s
�z#BaseEventLoop.set_exception_handlerc	Cs|�d�}|sd}|�d�}|dur6t|�||jf}nd}d|vr`|jdur`|jjr`|jj|d<|g}t|�D]�}|dvr|qn||}|dkr�d�t�|��}d	}||�	�7}n2|dkr�d�t�|��}d
}||�	�7}nt
|�}|�|�d|���qntj
d�|�|d
�dS)Nr�z!Unhandled exception in event looprTFZsource_tracebackZhandle_traceback>rTr�r/z+Object created at (most recent call last):
z+Handle created at (most recent call last):
rb�
r�)�getr@�
__traceback__r�r��sortedr
�	traceback�format_list�rstriprr;rr�)	rhr$r�rTr�Z	log_linesr��value�tbrrr�default_exception_handler�s<

���z'BaseEventLoop.default_exception_handlercCs�|jdurRz|�|�Wq�ttfy0�Yq�tyNtjddd�Yq�0n�z|�||�Wn�ttfyz�Ynrty�}zZz|�d||d��Wn6ttfy��Yn ty�tjddd�Yn0WYd}~n
d}~00dS)Nz&Exception in default exception handlerTr�z$Unhandled error in exception handler)r�rTr$zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rUrVr�rr�)rhr$rYrrrr�s4
���z$BaseEventLoop.call_exception_handlercCs|jr
dS|j�|�dSrD)�
_cancelledr�r;�rhrrrr�
_add_callbackszBaseEventLoop._add_callbackcCs|�|�|��dSrD)r�r�r�rrr�_add_callback_signalsafe
s
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dSr\)r�r�r�rrr�_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc	Cs�t|j�}|tkr`|j|tkr`g}|jD]}|jr<d|_q*|�|�q*t�|�||_d|_n4|jr�|jdjr�|jd8_t�	|j�}d|_q`d}|j
s�|jr�d}n*|jr�|jdj}t
td||���t�}|j�|�}|�|�|��|j}|j�r:|jd}|j|k�r�q:t�	|j�}d|_|j
�|�q�t|j
�}t|�D]�}	|j
��}|j�rf�qL|j�r�zJ||_|��}
|��|��|
}||jk�r�t�dt|�|�Wd|_nd|_0n|���qLd}dS)NFrrzExecuting %s took %.3f seconds)r�r��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�r;r,�heapify�heappopr�r�Z_whenrU�maxr��MAXIMUM_SELECT_TIMEOUT�	_selector�selectr�r��range�popleftrr�Z_runr�rr�r)rhZsched_countZ
new_scheduledr�timeoutr.r��end_timeZntodo�irBrDrrrrsh
��





�zBaseEventLoop._run_oncecCsHt|�t|j�krdS|r2t��|_t�tj�nt�|j�||_dSrD)r�r�r�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH�rhZenabledrrrres���z,BaseEventLoop._set_coroutine_origin_trackingcCs|jSrD)rrtrrrr�tszBaseEventLoop.get_debugcCs ||_|��r|�|j|�dSrD)rr�r�rr�rrrr�wszBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)N)NN)FN)rN)NN)NN)Vrr�r�rjr�rfr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr
rrrrrWr�r�r�r�r#r�r�r)r%r/r+r0r*r�r4r;rEr>rGrQrKrMrJrmr�r�r�r�r�r�r�r�r%r3r~r�r8�
AI_PASSIVEr�r�r�r�r�rrr�r�r�r�r�rr�r�r�rrr�r�rrrrr�s���
�
�
�
�
		
&	
	�

�
%���
�/�/���	��w��%�"29Nr)rr)r)6rH�collections.abc�concurrent.futuresr5rvr,rMr�r%r�rrr�r�rr�r�rn�ImportErrorr/rrrrrrr	r
rrr
�logr�__all__r�r�r$r:r��objectr�rr"r,rCrRrZr]�Protocolr^ZAbstractServerr�ZAbstractEventLooprrrrr�<module>sb

		
;


Do