ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/asyncio/__pycache__/base_events.cpython-38.opt-2.pyc

U

.��c��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZzddlZWnek
r�dZYnXddlmZddlmZddlmZddlmZddlmZddlmZdd	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__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�8/opt/alt/python38/lib64/python3.8/asyncio/base_events.py�_format_handleJs
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeSs


r!cCsLttd�std��n4z|�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_reuseport\s

r+c		Cs�ttd�sdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|t�rz|dkrzd}n@t|t�r�|dkr�d}n(zt	|�}Wnt
tfk
r�YdSX|tjkr�tj
g}tr�|�tj�n|g}t|t�r�|�d�}d|k�rdS|D]t}zVt�||�t�rJ|tjk�rJ|||d||||ffWS|||d||ffWSWntk
�rzYnX�q
dS)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_infogsN
�






rAcCs�t��}|D]*}|d}||kr(g||<||�|�qt|���}g}|dkr||�|dd|d��|dd|d�=|�dd�tj�tj	|��D��|S)Nrrcss|]}|dk	r|VqdS�Nr)�.0�arrr�	<genexpr>�s�z(_interleave_addrinfos.<locals>.<genexpr>)
�collections�OrderedDictr9�list�values�extend�	itertools�chain�
from_iterable�zip_longest)Z	addrinfosZfirst_address_family_countZaddrinfos_by_family�addrr=Zaddrinfos_listsZ	reorderedrrr�_interleave_addrinfos�s"
��rPcCs4|��s"|��}t|ttf�r"dSt�|���dSrB)�	cancelled�	exceptionr�
SystemExit�KeyboardInterruptrZ	_get_loop�stop)�fut�excrrr�_run_until_complete_cb�s
rX�TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|�tjtj	d�dS�Nr)
r=r$r7rr>r1r?r0r&rYr)rrr�_set_nodelay�s
�
�r[cCsdSrBrr)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_FlowControlMixinr5�
_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)r]�
is_closing�ConnectionErrorre)rfrVrrr�drain�s
z_SendfileFallbackProtocol.draincCstd��dS)Nz?Invalid state: connection should have been established already.��RuntimeError)rf�	transportrrr�connection_made�sz)_SendfileFallbackProtocol.connection_madecCs@|jdk	r0|dkr$|j�td��n|j�|�|j�|�dS)NzConnection is closed by peer)reZ
set_exceptionrjr^�connection_lost)rfrWrrrrp�s
�z)_SendfileFallbackProtocol.connection_lostcCs |jdk	rdS|jj��|_dSrB)rer]rcrd�rfrrr�
pause_writing�s
z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|j�d�d|_dS)NF)re�
set_resultrqrrr�resume_writing�s
z(_SendfileFallbackProtocol.resume_writingcCstd��dS�Nz'Invalid state: reading should be pausedrl)rf�datarrr�
data_received�sz'_SendfileFallbackProtocol.data_receivedcCstd��dSrurlrqrrr�eof_receivedsz&_SendfileFallbackProtocol.eof_receivedc�sF|j�|j�|jr|j��|jdk	r2|j��|jrB|j��dSrB)	r]rbr^r_�resume_readingre�cancelr`rtrqrrr�restores


z!_SendfileFallbackProtocol.restoreN)�__name__�
__module__�__qualname__rhrkrorprrrtrwrxr{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)
rc�_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_serving�_serving_forever_fut)rf�loop�sockets�protocol_factoryZssl_context�backlog�ssl_handshake_timeoutrrrrhszServer.__init__cCsd|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__r|r�rqrrr�__repr__ szServer.__repr__cCs|jd7_dSrZ)r�rqrrr�_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|��dS)Nrr)r�r��_wakeuprqrrr�_detach'szServer._detachcCs,|j}d|_|D]}|��s|�|�qdSrB)r��doners)rf�waiters�waiterrrrr�-s
zServer._wakeupc	CsJ|jr
dSd|_|jD].}|�|j�|j�|j||j||j|j�qdS�NT)	r�r�Zlistenr�rc�_start_servingr�r�r�)rfr*rrrr�4s
�zServer._start_servingcCs|jSrB)rcrqrrr�get_loop>szServer.get_loopcCs|jSrB)r�rqrrr�
is_servingAszServer.is_servingcCs"|jdkrdStdd�|jD��S)Nrcss|]}t�|�VqdSrB)r
ZTransportSocket)rC�srrrrEHsz!Server.sockets.<locals>.<genexpr>)r��tuplerqrrrr�Ds
zServer.socketscCsn|j}|dkrdSd|_|D]}|j�|�qd|_|jdk	rX|j��sX|j��d|_|jdkrj|��dS)NFr)	r�rcZ
_stop_servingr�r�r�rzr�r�)rfr�r*rrr�closeJs
�

zServer.closec�s"|��tjd|jd�IdHdS)Nr�r�)r�r�sleeprcrqrrr�
start_serving]szServer.start_servingc	�s�|jdk	rtd|�d���|jdkr4td|�d���|��|j��|_zLz|jIdHWn6tjk
r�z|��|�	�IdHW5�XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
r�rmr�r�rcrdrZCancelledErrorr��wait_closedrqrrr�
serve_forevercs 

�
zServer.serve_foreverc�s<|jdks|jdkrdS|j��}|j�|�|IdHdSrB)r�r�rcrdr9)rfr�rrrr�xs

zServer.wait_closedN)r|r}r~rhr�r�r�r�r�r�r��propertyr�r�r�r�r�rrrrrs


rc@sPeZdZdd�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�Zejfd7d8�Zd9d:�Zd;d<�Zdd=�d>d?�Z dd=�d@dA�Z!dd=�dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dd=�dJdK�Z&dLdM�Z'dNdO�Z(dPdQ�Z)dRdRdRdRdS�dTdU�Z*d�dVdW�Z+d�ddX�dYdZ�Z,d[d\�Z-d]d^�Z.d_d`�Z/d�dadb�Z0d�ddRdRdRdddddddc�
ddde�Z1d�dfdg�Z2d�ddX�dhdi�Z3djdk�Z4dldm�Z5ddddn�dodp�Z6d�dRdRdRe7ddddq�drds�Z8dRe9j:dRdRdS�dtdu�Z;dvdw�Z<d�e9j=e9j>ddxddddddy�	dzd{�Z?ddd|�d}d~�Z@dd��ZAd�d��ZBd�d��ZCeDjEeDjEeDjEdddRdddd��	d�d��ZFeDjEeDjEeDjEdddRdddd��	d�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRdS)�rcCs�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�	_stoppingrF�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�weakrefZWeakSet�
_asyncgens�_asyncgens_shutdown_calledrqrrrrh�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_debugrqrrrr��s,�zBaseEventLoop.__repr__cCstj|d�S)Nr�)rZFuturerqrrrrd�szBaseEventLoop.create_futureN)�namecCsN|��|jdkr2tj|||d�}|jrJ|jd=n|�||�}t�||�|S)N)r�r����)�
_check_closedr�rr�_source_tracebackZ_set_task_name)rf�coror�Ztaskrrr�create_task�s

zBaseEventLoop.create_taskcCs"|dk	rt|�std��||_dS)Nz'task factory must be a callable or None)�callabler5r�)rf�factoryrrr�set_task_factory�s
zBaseEventLoop.set_task_factorycCs|jSrB)r�rqrrr�get_task_factory�szBaseEventLoop.get_task_factory)�extra�servercCst�dSrB��NotImplementedError)rfr*�protocolr�r�r�rrr�_make_socket_transport�sz$BaseEventLoop._make_socket_transportFT)�server_side�server_hostnamer�r�r��call_connection_madecCst�dSrBr�)rfZrawsockr��
sslcontextr�r�r�r�r�r�r�rrr�_make_ssl_transport�sz!BaseEventLoop._make_ssl_transportcCst�dSrBr�)rfr*r��addressr�r�rrr�_make_datagram_transport�sz&BaseEventLoop._make_datagram_transportcCst�dSrBr��rf�piper�r�r�rrr�_make_read_pipe_transport�sz'BaseEventLoop._make_read_pipe_transportcCst�dSrBr�r�rrr�_make_write_pipe_transport�sz(BaseEventLoop._make_write_pipe_transportc	
�st�dSrBr�)
rfr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transport�sz(BaseEventLoop._make_subprocess_transportcCst�dSrBr�rqrrr�_write_to_self�szBaseEventLoop._write_to_selfcCst�dSrBr�)rf�
event_listrrr�_process_events�szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)r�rmrqrrrr��szBaseEventLoop._check_closedcCs*|j�|�|��s&|�|j|���dSrB)r��discardr��call_soon_threadsafer��aclose�rf�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��addr�rrr�_asyncgen_firstiter_hooks
�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�)rCZagrrr�
<listcomp>sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsr�z;an error occurred during closing of asynchronous generator )�messagerRZasyncgen)r��lenr�rH�clearr�gather�zipr�	Exception�call_exception_handler)rfZ
closing_agensZresults�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�rmrZ_get_running_looprqrrr�_check_running&s�zBaseEventLoop._check_runningc	Cs�|��|��|�|j�t��|_t��}tj	|j
|jd�z t
�|�|��|jrLq^qLW5d|_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�r�rZ_set_running_loop�	_run_once)rfZold_agen_hooksrrr�run_forever-s$
�


zBaseEventLoop.run_foreverc	Cs�|��|��t�|�}tj||d�}|r4d|_|�t�z<z|�
�Wn*|rp|��rp|��sp|�
��YnXW5|�	t�X|��s�td��|��S)Nr�Fz+Event loop stopped before Future completed.)r�r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrXZremove_done_callbackrr�rQrRrmr�)rfZfutureZnew_taskrrr�run_until_completeDs"
z BaseEventLoop.run_until_completecCs
d|_dSr�)r�rqrrrrUjszBaseEventLoop.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�rmr�r�r�debugr�r�r�r�Zshutdown�rf�executorrrrr�rs

zBaseEventLoop.closecCs|jSrB)r�rqrrrr��szBaseEventLoop.is_closedcCs0|��s,|d|��t|d�|��s,|��dS)Nzunclosed event loop r�)r�r�r�r�)rfZ_warnrrr�__del__�szBaseEventLoop.__del__cCs
|jdk	SrB)r�rqrrrr��szBaseEventLoop.is_runningcCst��SrB)r�r�rqrrrr��szBaseEventLoop.time)�contextcGs2|j|��||f|�d|i�}|jr.|jd=|S)Nr
r�)�call_atr�r�)rfZdelay�callbackr
r��timerrrr�
call_later�s�zBaseEventLoop.call_latercGsZ|��|jr"|��|�|d�t�|||||�}|jrB|jd=t�|j	|�d|_	|S)Nrr�T)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushr�)rf�whenrr
r�rrrrr�szBaseEventLoop.call_atcGsB|��|jr"|��|�|d�|�|||�}|jr>|jd=|S)N�	call_soonr�)r�r�rr�
_call_soonr��rfrr
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 )rZiscoroutineZiscoroutinefunctionr5r�)rfr�methodrrrr�s
�
��zBaseEventLoop._check_callbackcCs.t�||||�}|jr|jd=|j�|�|S)Nr�)rZHandler�r�r9)rfrr�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�rrrm)rfZ	thread_idrrrr�s	

�zBaseEventLoop._check_threadcGsB|��|jr|�|d�|�|||�}|jr6|jd=|��|S)Nr�r�)r�r�rrr�r�rrrrr��sz"BaseEventLoop.call_soon_threadsafecGsZ|��|jr|�|d�|dkr@|j}|dkr@tj��}||_tj|j|f|��|d�S)N�run_in_executorr�)	r�r�rr��
concurrentr�ThreadPoolExecutorZwrap_futureZsubmit)rfr�funcr�rrrrs
�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�)rrrrr�r��DeprecationWarningr�r
rrr�set_default_executors�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: )	r9�joinrr	r�r$�getaddrinfor��info)rfr;r<r=r>r?�flags�msg�t0�addrinfo�dtrrr�_getaddrinfo_debugs&


z BaseEventLoop._getaddrinfo_debugr�r=r>r?r'c
�s2|jr|j}ntj}|�d|||||||�IdHSrB)r�r,r$r%r)rfr;r<r=r>r?r'Zgetaddr_funcrrrr%2s�zBaseEventLoop.getaddrinfoc�s|�dtj||�IdHSrB)rr$�getnameinfo)rfZsockaddrr'rrrr.<s�zBaseEventLoop.getnameinfo)�fallbackc
�s�|jr|��dkrtd��|�||||�z|�||||�IdHWStjk
rl}z
|s\�W5d}~XYnX|�||||�IdHS)Nrzthe socket must be non-blocking)r�Z
gettimeoutr%�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)rfr*�file�offset�countr/rWrrr�
sock_sendfile@s��zBaseEventLoop.sock_sendfilec�st�d|�d���dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination�rr2�rfr*r4r5r6rrrr1Ns
�z#BaseEventLoop._sock_sendfile_nativec

�s�|r|�|�|rt|tj�ntj}t|�}d}zt|rNt|||�}|dkrNq�t|�d|�}|�d|j|�IdH}	|	szq�|�	||d|	��IdH||	7}q2|W�S|dkr�t|d�r�|�||�XdS)Nr�seek)
r:�minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearrayr#�
memoryviewr�readintoZsock_sendall)
rfr*r4r5r6�	blocksize�buf�
total_sent�view�readrrrr3Us,
��
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$r1rr4r5�formatr9rrrr0os2
��
����z$BaseEventLoop._check_sendfile_paramsc�s@g}|�|�|\}}}}}	d}
z�tj|||d�}
|
�d�|dk	r�|D]r\}}}}}z|
�|�Wq�WqHtk
r�}z0d|�d|j����}
t|j|
�}|�|�W5d}~XYqHXqH|���|�	|
|	�IdH|
WStk
�r}z"|�|�|
dk	�r
|
�
��W5d}~XYn |
dk	�r4|
�
��YnXdS)N�r=r>r?Fz*error while attempting to bind on address �: )r9r$�setblocking�bindr(�strerror�lower�errno�pop�sock_connectr�)rfrZ	addr_infoZlocal_addr_infosZ
my_exceptionsr=Ztype_r?�_r�r*ZladdrrWr(rrr�
_connect_sock�s:



�


zBaseEventLoop._connect_sock)
�sslr=r?r'r*�
local_addrr�r��happy_eyeballs_delay�
interleavec
	�sl|
dk	r|std��|
dkr0|r0|s,td��|}
|dk	rD|sDtd��|dk	rX|
dkrXd}
|dk	sj|dk	�r�|dk	rztd���j||f|tj||�d�IdH}|s�td��|	dk	r܈j|	|tj||�d�IdH��s�td��nd�|
r�t||
�}g�|dk�rH|D]D}z ���|��IdH}W�qvWntk
�r@Y�qYnX�qn.tj���fdd	�|D�|�d
�IdH\}}}|dk�r dd��D��t	��dk�r��d
�nJt
�d
��t�fdd	��D���r҈d
�td�d�
dd	��D�����n.|dk�rtd��|jtjk�r td|�����j||||
|d�IdH\}}�j�rd|�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>r?r'r��!getaddrinfo() returned empty listc3s |]}t��j�|��VqdSrB)�	functools�partialrQ)rCr*)r�laddr_infosrfrrrE�s��z2BaseEventLoop.create_connection.<locals>.<genexpr>r�cSsg|]}|D]}|�qqSrr)rC�subrWrrrr��sz3BaseEventLoop.create_connection.<locals>.<listcomp>rc3s|]}t|��kVqdSrB�r�rCrW)�modelrrrEszMultiple exceptions: {}r#css|]}t|�VqdSrBr^r_rrrrE
sz5host 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$r1r(rPrQr
Zstaggered_racer�r�allrFr$r>�_create_connection_transportr��get_extra_inforr	)rfr�r;r<rRr=r?r'r*rSr�r�rTrU�infosr*rPrnr�r)rr\r`rfr�create_connection�s�����


�
��

�
���
�zBaseEventLoop.create_connectionc	�s�|�d�|�}|��}|rHt|t�r*dn|}	|j|||	||||d�}
n|�|||�}
z|IdHWn|
���YnX|
|fS)NF�r�r�r�)rIrdr�boolr�r�r�)rfr*r�rRr�r�r�r�r�r�rnrrrrd%s*
�z*BaseEventLoop._create_connection_transportc
�s�|��rtd��t|dtjj�}|tjjkr:td|����|tjjkr�z|�||||�IdHWStj	k
r�}z
|sx�W5d}~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 )rirmrrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE�_sendfile_nativerr2�_sendfile_fallback)rfrnr4r5r6r/rErWrrr�sendfile?s4�����zBaseEventLoop.sendfilec�st�d��dS)Nz!sendfile syscall is not supportedr8)rfrgr4r5r6rrrrjns�zBaseEventLoop._sendfile_nativec
�s�|r|�|�|rt|d�nd}t|�}d}t|�}z�|rXt|||�}|dkrX|W�bSt|�d|�}	|�d|j|	�IdH}
|
s�|W�0S|�	�IdH|�
|	d|
��||
7}q6W5|dkr�t|d�r�|�||�|��IdHXdS)Ni@rr:)r:r;r<r\r#r{r=rr>rk�write)rfrgr4r5r6r?r@rAr?rBrCrrrrkrs*
z BaseEventLoop._sendfile_fallbackrhc
�s�tdkrtd��t|tj�s*td|����t|dd�sFtd|�d���|��}tj|||||||dd�}|�	�|�
|�|�|j|�}	|�|j
�}
z|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())r�r�)rRrmrZ
SSLContextr5rrdr	ZSSLProtocolrarbrrory�
BaseExceptionr�rzZ_app_transport)rfrnr�r�r�r�r�r�Zssl_protocolZ
conmade_cbZ	resume_cbrrr�	start_tls�sB	�
��
zBaseEventLoop.start_tls)r=r?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�r���fD]}|dk	r�t
|t�s�td
��qڈ�rx�d	dk�rxz"t
�t�
��j��r.t���WnFtk
�rFYn2tk
�rv}zt�d�|�W5d}~XYnX||f��fff}n�i}d	�fd�ffD]�\}}|dk	�r�|j||tj|||d�IdH}|�s�td��|D]:\}}}}}||f}||k�rddg||<||||<�q�q���fdd�|��D�}|�sHtd��g}|tk	�rv|�rftd��ntjdtdd�|D]�\\}}\}}d}
d}
zxtj|tj|d�}
|�r�t|
�|	�r�|
�tjtjd�|
�d���r�|
�|���r|	�s|� |
|�IdH|}
Wn^tk
�rJ}z |
dk	�r0|
�!�|�"|�W5d}~XYn&|
dk	�rb|
�!��YnX�q|�qz|d	�|�}|�#�}|�$|
||
|�}|j%�r̈�r�t�&d��||�nt�'d�||�z|IdHWn|�!��YnX||fS)NzA UDP Socket was expected, got )rS�remote_addrr=r?r'rprqrrr#css$|]\}}|r|�d|��VqdS)�=Nr)rC�k�vrrrrE�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 expected)r�z2Unable to check or remove stale UNIX socket %r: %rrrXrYcs8g|]0\}}�r|ddks�r,|ddks||f�qS)rNrr)rC�keyZ	addr_pair�rSrsrrr��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.r)�
stacklevelrGz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%�dictr$�itemsrIr#rxrrr5�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr(r�errorrb�_unsetr�r�r r+r&r'ZSO_BROADCASTrJrOr�r9rdr�r�r&r	) rfr�rSrsr=r?r'rprqrrr*ZoptsZproblemsZr_addrZaddr_pairs_inforO�errZ
addr_infos�idxrfZfamrPZpror�rzrZ
local_addressZremote_addressrWr�r�rnrr{r�create_datagram_endpoint�s$�������
�

��
�
�

����




���z&BaseEventLoop.create_datagram_endpointc
�s\|dd�\}}t|||||f|dd���}	|	dk	r<|	gS|j||||||d�IdHSdS)Nrr-)rAr%)
rfr�r=r>r?r'r�r;r<r&rrrrbLs�zBaseEventLoop._ensure_resolvedc�s8|j||f|tj||d�IdH}|s4td|�d���|S)N)r=r>r'r�zgetaddrinfo(z) returned empty list)rbr$r1r()rfr;r<r=r'rfrrr�_create_server_getaddrinfoXs�z(BaseEventLoop._create_server_getaddrinfor)	r=r'r*r�rRrprqr�r�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|D�]}|\}}}}}zt�|||�}Wn8tjk
�rH�j�r@tjd|||dd
�Yq�YnX|
�|�|	�rl|�tjtjd�|
�rzt|�t�r�|tjk�r�ttd��r�|�tj tj!d�z|�"|�Wq�t#k
�r�}z t#|j$d||j%�&�f�d�W5d}~XYq�Xq�d}W5|�s|
D]}|���qXn4|dk�r4td��|j'tj(k�rPtd|����|g}
|
D]}|�)d
��qZt*�|
||||�}|�r�|�+�tj,d�d�IdH�j�r�t�-d|�|S)Nz*ssl argument must be an SSLContext or NonerVrW�posix�cygwinr.csg|]}�j|���d��qS))r=r')r�)rCr;�r=r'r<rfrrr��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 specifiedrarr�z
%r is serving).rrir5r%r�r�r�platformrrF�abc�Iterablerr��setrKrLrMr�r$r�r�r�warningr9r&r'ZSO_REUSEADDRr+r8rr#r�ZIPV6_V6ONLYrJr(rMrKrLr>r1rIrr�r�r&)rfr�r;r<r=r'r*r�rRrprqr�r�r�ZhostsZfsrfZ	completed�resr@Zsocktyper?Z	canonnameZsar�r�rr�r�
create_server`s�
��
��
�

������
�zBaseEventLoop.create_server)rRr�c�sv|jtjkrtd|����|dk	r.|s.td��|j|||dd|d�IdH\}}|jrn|�d�}t�d|||�||fS)NrarVr.T)r�r�r$z%r handled: (%r, %r))	r>r$r1r%rdr�rerr	)rfr�r*rRr�rnr�rrr�connect_accepted_socket�s$��
z%BaseEventLoop.connect_accepted_socketc�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz Read pipe %r connected: (%r, %r))rdr�r�r�rr	�fileno�rfr�r�r�r�rnrrr�connect_read_pipe�s�zBaseEventLoop.connect_read_pipec�sd|�}|��}|�|||�}z|IdHWn|���YnX|jr\t�d|��||�||fS)Nz!Write pipe %r connected: (%r, %r))rdr�r�r�rr	r�r�rrr�connect_write_pipes�z 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=� )r9r!rrrr	r$)rfr(r�r�r�r&rrr�_log_subprocessszBaseEventLoop._log_subprocess)	r�r�r��universal_newlinesr�r��encoding�errors�textc	�s�t|ttf�std��|r"td��|s.td��|dkr>td��|rJtd��|	dk	rZtd��|
dk	rjtd��|�}
d}|jr�d	|}|�||||�|j|
|d
||||f|�IdH}|jr�|dk	r�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)	rr3rr%r�r�r�rr&)rfr��cmdr�r�r�r�r�r�r�r�r�r�r��	debug_logrnrrr�subprocess_shellsB��
zBaseEventLoop.subprocess_shellc	�s�|rtd��|rtd��|dkr(td��|r4td��|	dk	rDtd��|
dk	rTtd��|f|}|�}d}|jr�d|��}|�||||�|j||d	||||f|
�IdH}|jr�|dk	r�t�d
||�||fS)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r%r�r�r�rr&)rfr�Zprogramr�r�r�r�r�r�r�r�r�r�r�Z
popen_argsr�r�rnrrr�subprocess_execCs@

��
zBaseEventLoop.subprocess_execcCs|jSrB)r�rqrrr�get_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk	rt|�std|����||_dS)Nz+A callable object or None is expected, got )r�r5r�)rfZhandlerrrr�set_exception_handlerjsz#BaseEventLoop.set_exception_handlerc	Cs|�d�}|sd}|�d�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}t|�D]�}|dkr|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 looprRFZsource_tracebackZhandle_traceback>rRr�r.z+Object created at (most recent call last):
z+Handle created at (most recent call last):
rH�
r�)�getr>�
__traceback__r�r��sortedr$�	traceback�format_list�rstriprr9rr�)	rfr
r�rRr�Z	log_linesrz�value�tbrrr�default_exception_handler{s<

���z'BaseEventLoop.default_exception_handlercCs�|jdkrVz|�|�Wq�ttfk
r2�Yq�tk
rRtjddd�Yq�Xn�z|�||�Wn�ttfk
r��Ynttk
r�}zVz|�d||d��Wn:ttfk
r��Yn"tk
r�tjddd�YnXW5d}~XYnXdS)Nz&Exception in default exception handlerTr�z$Unhandled error in exception handler)r�rRr
zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rSrTrnrr�)rfr
rWrrrr��s4
���z$BaseEventLoop.call_exception_handlercCs|jr
dS|j�|�dSrB)�
_cancelledr�r9�rfrrrr�
_add_callback�szBaseEventLoop._add_callbackcCs|�|�|��dSrB)r�r�r�rrr�_add_callback_signalsafe�s
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dSrZ)r�r�r�rrr�_timer_handle_cancelled�sz%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�zD||_|��}
|��|��|
}||jk�r�t�dt|�|�W5d|_Xn|���qLd}dS)NFrrzExecuting %s took %.3f seconds)r�r��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�r9r�heapify�heappopr�r�Z_whenr;�maxr��MAXIMUM_SELECT_TIMEOUTZ	_selectorZselectr�r��range�popleftr�r�Z_runr�rr�r)rfZsched_countZ
new_scheduledrZtimeoutrr�Zend_timeZntodo�ir)r+rrrr�sj
��





�
zBaseEventLoop._run_oncecCsHt|�t|j�krdS|r2t��|_t�tj�nt�|j�||_dSrB)rir�r�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH�rfZenabledrrrr�Fs���z,BaseEventLoop._set_coroutine_origin_trackingcCs|jSrB)r�rqrrrr�UszBaseEventLoop.get_debugcCs ||_|��r|�|j|�dSrB)r�r�r�r�r�rrrr�XszBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)N)NN)FN)rN)NN)NN)Sr|r}r~rhr�rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrUr�r�r�r�rr�r�rrrrrrr�rr!r,r%r.r7r1r3r0rQrgrdrlrjrkror�r�r$r1rbr�r6Z
AI_PASSIVEr�r�r�r�r�rrr�r�r�r�r�r�r�r�r�rr�r�r�rrrrr�sF���
�
�
�
�
		&	
	�

�
%���
�/�/���	��w��%�"29Nr)rr)r)6rFZcollections.abcZconcurrent.futuresrrZrrKr�r$rrrr�r�rr�r�rR�ImportErrorr.rrrrrrr	r
rrr
�logr�__all__r�r�r#r8r��objectr�rr!r+rArPrXr[ZProtocolr\ZAbstractServerrZAbstractEventLooprrrrr�<module>sb

		
;


Do

Zerion Mini Shell 1.0