AlkantarClanX12

Your IP : 3.145.33.244


Current Path : /usr/lib64/python3.6/asyncio/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/asyncio/__pycache__/base_events.cpython-36.opt-2.pyc

3


 \��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZd
gZdZdZeeefZe ed
�Z!d(Z"dd�Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dej)ddd�dd�Z*e ed��rNd d!�Z+nd"d!�Z+d#d$�Z,Gd%d&�d&ej-�Z.Gd'd
�d
ej/�Z0dS))�N�)�compat)�
coroutines)�events)�futures)�tasks)�	coroutine)�logger�
BaseEventLoop�dg�?�AF_INET6�icCs0|j}tt|dd�tj�r$t|j�St|�SdS)N�__self__)Z	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cb�r�+/usr/lib64/python3.6/asyncio/base_events.py�_format_handle?s
rcCs(|tjkrdS|tjkrdSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeHs


rcCsLttd�std��n4y|jtjtjd�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_reuseportQs

r&cCs&ttd�r|d@tjkS|tjkSdS)N�
SOCK_NONBLOCK�)rr �SOCK_STREAM)�	sock_typerrr�_is_stream_socket\s
r+cCs&ttd�r|d@tjkS|tjkSdS)Nr'r()rr �
SOCK_DGRAM)r*rrr�_is_dgram_sockeths
r-cCsvttd�sdS|dtjtjhks(|dkr,dSt|�r<tj}nt|�rLtj}ndS|dkr^d}nVt|t�rv|dkrvd}n>t|t�r�|dkr�d}n&yt	|�}Wnt
tfk
r�dSX|tjkr�tj
g}tr�|jtj�n|g}t|t�r�|jd�}d|k�rdSxp|D]h}yJtj||�t�r@|tjk�r@|||d||ddffS|||d||ffSWntk
�rjYnX�qWdS)N�	inet_ptonr��Zidna�%)rr �IPPROTO_TCPZIPPROTO_UDPr+r-r�bytesr�int�	TypeErrorr!�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder.r$)�host�port�family�type�protoZafs�afrrr�_ipaddr_infopsL





rA)r=r>r?�flagsc
CsZ|dd�\}}t|||||�}|dk	r@|j�}	|	j|g�|	S|j||||||d�SdS)N�)r=r>r?rB)rA�
create_future�
set_result�getaddrinfo)
�addressr=r>r?rB�loopr;r<�info�futrrr�_ensure_resolved�srK�TCP_NODELAYcCs>|jtjtjhkr:t|j�r:|jtjkr:|jtjtj	d�dS)Nr)
r=r r7rr+r>r?r2r"rL)r%rrr�_set_nodelay�s
rMcCsdS)Nr)r%rrrrM�scCs.|j}t|t�r t|t�r dS|jj�dS)N)Z
_exceptionr�
BaseException�	Exception�_loop�stop)rJ�excrrr�_run_until_complete_cb�s

rSc@sHeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dS)�ServercCs||_||_d|_g|_dS)Nr)rP�sockets�
_active_count�_waiters)�selfrHrUrrr�__init__�szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>)�	__class__�__name__rU)rXrrr�__repr__�szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr�_attach�szServer._attachcCs.|jd8_|jdkr*|jdkr*|j�dS)Nrr)rVrU�_wakeup)rXrrr�_detach�szServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|�qW|jdkrD|j�dS)Nr)rUrPZ
_stop_servingrVr^)rXrUr%rrr�close�s

zServer.closecCs0|j}d|_x|D]}|j�s|j|�qWdS)N)rW�donerE)rX�waiters�waiterrrrr^�s

zServer._wakeupccs<|jdks|jdkrdS|jj�}|jj|�|EdHdS)N)rUrWrPrDr9)rXrcrrr�wait_closed�s

zServer.wait_closedN)r[�
__module__�__qualname__rYr\r]r_r`r^rrdrrrrrT�s
rTc
@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd�d
d
d�dd�Z	d�dd
d
d
d�dd�Z
d�dd�Zd�dd�Zd�dd�Z
ed�dd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zed'd(��Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zej�r�d3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdMdMdMdN�dOdP�Z*d�dQdR�Z+ed�d
dMdMdMd
d
d
dS�dTdU��Z,ed�dVdW��Z-ed�dMdMdMd
d
d
d
dX�dYdZ��Z.ed[d\��Z/ed�e0j1e0j2d
d]d
d
d
d^�d_d`��Z3ed
da�dbdc��Z4eddde��Z5edfdg��Z6dhdi�Z7ee8j9e8j9e8j9ddjdMdk�dldm��Z:ee8j9e8j9e8j9dddMdk�dndo��Z;dpdq�Z<drds�Z=dtdu�Z>dvdw�Z?dxdy�Z@dzd{�ZAd|d}�ZBd~d�ZCd�d��ZDd�d��ZEd�d��ZFd
S)�r
cCs�d|_d|_d|_tj�|_g|_d|_d|_d|_	t
jd�j|_
d|_|jtjjodttjjd���d|_d|_d|_d|_ttd�r�tj�|_nd|_d|_dS)NrF�	monotonicZPYTHONASYNCIODEBUGg�������?�get_asyncgen_hooks) �_timer_cancelled_count�_closed�	_stopping�collections�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�timeZget_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debug�sysrB�ignore_environment�bool�os�environ�get�slow_callback_duration�_current_handle�
_task_factory�_coroutine_wrapper_setr�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called)rXrrrrY�s(

zBaseEventLoop.__init__cCs d|jj|j�|j�|j�fS)Nz"<%s running=%s closed=%s debug=%s>)rZr[�
is_running�	is_closed�	get_debug)rXrrrr\ szBaseEventLoop.__repr__cCstj|d�S)N)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j�|jdkr0tj||d�}|jr<|jd=n|j||�}|S)N)rHr���)�
_check_closedr~rr�_source_traceback)rX�coroZtaskrrr�create_task)s

zBaseEventLoop.create_taskcCs$|dk	rt|�rtd��||_dS)Nz'task factory must be a callable or None)�callabler5r~)rX�factoryrrr�set_task_factory7s
zBaseEventLoop.set_task_factorycCs|jS)N)r~)rXrrr�get_task_factoryEszBaseEventLoop.get_task_factoryN)�extra�servercCst�dS)N)�NotImplementedError)rXr%�protocolrcr�r�rrr�_make_socket_transportIsz$BaseEventLoop._make_socket_transportF)�server_side�server_hostnamer�r�c	Cst�dS)N)r�)	rXZrawsockr��
sslcontextrcr�r�r�r�rrr�_make_ssl_transportNsz!BaseEventLoop._make_ssl_transportcCst�dS)N)r�)rXr%r�rGrcr�rrr�_make_datagram_transportTsz&BaseEventLoop._make_datagram_transportcCst�dS)N)r�)rX�piper�rcr�rrr�_make_read_pipe_transportYsz'BaseEventLoop._make_read_pipe_transportcCst�dS)N)r�)rXr�r�rcr�rrr�_make_write_pipe_transport^sz(BaseEventLoop._make_write_pipe_transportc	
Kst�dS)N)r�)
rXr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transportcsz(BaseEventLoop._make_subprocess_transportcCst�dS)N)r�)rXrrr�_write_to_selfjszBaseEventLoop._write_to_selfcCst�dS)N)r�)rX�
event_listrrr�_process_eventssszBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)rj�RuntimeError)rXrrrr�wszBaseEventLoop._check_closedcCs*|jj|�|j�s&|j|j|j��dS)N)r��discardr��call_soon_threadsafer��aclose)rX�agenrrr�_asyncgen_finalizer_hook{sz&BaseEventLoop._asyncgen_finalizer_hookcCs,|jrtjdj|�t|d�|jj|�dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call)�source)r��warnings�warn�format�ResourceWarningr��add)rXr�rrr�_asyncgen_firstiter_hook�s
z&BaseEventLoop._asyncgen_firstiter_hookccs�d|_|jdkst|j�r dSt|j�}|jj�tjdd�|D�d|d��}|EdH}x8t||�D]*\}}t|t	�rf|j
dj|�||d��qfWdS)NTcSsg|]}|j��qSr)r�)�.0Zagrrr�
<listcomp>�sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})�message�	exceptionZasyncgen)r�r��len�list�clearr�gather�ziprrO�call_exception_handlerr�)rXZ
closing_agensZ
shutdown_coroZresults�resultr�rrr�shutdown_asyncgens�s"




z BaseEventLoop.shutdown_asyncgenscCs�|j�|j�rtd��tj�dk	r,td��|j|j�tj�|_	|j
dk	rftj�}tj
|j|jd�z$tj|�x|j�|jrtPqtWWdd|_d|_	tjd�|jd�|j
dk	r�tj
|�XdS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)�	firstiter�	finalizerF)r�r�r�rZ_get_running_loop�_set_coroutine_wrapper�_debug�	threading�	get_identrqr�rvrh�set_asyncgen_hooksr�r�Z_set_running_loop�	_run_oncerk)rXZold_agen_hooksrrr�run_forever�s0







zBaseEventLoop.run_forevercCs�|j�tj|�}tj||d�}|r,d|_|jt�z>y|j�Wn,|rj|j	�rj|j
�rj|j��YnXWd|jt�X|j	�s�t
d��|j�S)N)rHFz+Event loop stopped before Future completed.)r�rZisfuturerZ
ensure_futureZ_log_destroy_pendingZadd_done_callbackrSr�raZ	cancelledr�Zremove_done_callbackr�r�)rXZfutureZnew_taskrrr�run_until_complete�s 
z BaseEventLoop.run_until_completecCs
d|_dS)NT)rk)rXrrrrQ�szBaseEventLoop.stopcCsj|j�rtd��|jrdS|jr,tjd|�d|_|jj�|jj�|j	}|dk	rfd|_	|j
dd�dS)Nz!Cannot close a running event loopzClose %rTF)�wait)r�r�rjr�r	�debugrnr�rorpZshutdown)rX�executorrrrr`�s

zBaseEventLoop.closecCs|jS)N)rj)rXrrrr�szBaseEventLoop.is_closedcCs0|j�s,tjd|t|d�|j�s,|j�dS)Nzunclosed event loop %r)r�)r�r�r�r�r�r`)rXrrr�__del__s
zBaseEventLoop.__del__cCs
|jdk	S)N)rq)rXrrrr�szBaseEventLoop.is_runningcCstj�S)N)rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j�||f|��}|jr(|jd=|S)Nrr�)�call_atrrr�)rXZdelay�callbackr��timerrrr�
call_later szBaseEventLoop.call_latercGsX|j�|jr"|j�|j|d�tj||||�}|jr@|jd=tj|j	|�d|_	|S)Nr�rTr�)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushro)rX�whenr�r�r�rrrr�5szBaseEventLoop.call_atcGs@|j�|jr"|j�|j|d�|j||�}|jr<|jd=|S)N�	call_soonrr�)r�r�r�r��
_call_soonr�)rXr�r�rrrrr�Es
zBaseEventLoop.call_sooncCs>tj|�stj|�r"tdj|���t|�s:tdj||���dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZiscoroutineZiscoroutinefunctionr5r�r�)rXr��methodrrrr�Xs

zBaseEventLoop._check_callbackcCs,tj|||�}|jr|jd=|jj|�|S)Nrr�)rZHandler�rnr9)rXr�r�rrrrr�cs
zBaseEventLoop._call_sooncCs,|jdkrdStj�}||jkr(td��dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rqr�r�r�)rXZ	thread_idrrrr�js	

zBaseEventLoop._check_threadcGs@|j�|jr|j|d�|j||�}|jr4|jd=|j�|S)Nr�rr�)r�r�r�r�r�r�)rXr�r�rrrrr�{sz"BaseEventLoop.call_soon_threadsafecGsZ|j�|jr|j|d�|dkr@|j}|dkr@tjj�}||_tj|j|f|��|d�S)N�run_in_executor)rH)	r�r�r�rp�
concurrentrZThreadPoolExecutorZwrap_futureZsubmit)rXr��funcr�rrrr��s
zBaseEventLoop.run_in_executorcCs
||_dS)N)rp)rXr�rrr�set_default_executor�sz"BaseEventLoop.set_default_executorcCs�d||fg}|r |jd|�|r2|jd|�|rD|jd|�|rV|jd|�dj|�}tjd|�|j�}tj||||||�}	|j�|}
d||
d	|	f}|
|jkr�tj|�n
tj|�|	S)
Nz%s:%rz	family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@�@)	r9�joinr	r�rrr rFr|rI)rXr;r<r=r>r?rB�msg�t0Zaddrinfo�dtrrr�_getaddrinfo_debug�s(


z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc	Cs>|jr |jd|j||||||�S|jdtj||||||�SdS)N)r�r�r�r rF)rXr;r<r=r>r?rBrrrrF�s


zBaseEventLoop.getaddrinfocCs|jdtj||�S)N)r�r �getnameinfo)rXZsockaddrrBrrrr��szBaseEventLoop.getnameinfo)�sslr=r?rBr%�
local_addrr�c#s|
dk	r|rtd��|
dkr2|r2|s.td��|}
|dk	sD|dk	�r�|dk	rTtd��t||f|tj|||d�}|g}|	dk	r�t|	|tj|||d�}
|j|
�nd}
tj||d�EdH|j�}|s�td��|
dk	r�|
j�}|s�td��g}�x�|D�]B\}}}}}y�tj|||d�}|j	d�|
dk	�r�x�|D]j\}}}}}y|j
|�PWnHtk
�r�}z*t|jd	j||j
j���}|j|�WYdd}~XnX�q.W|j�d}w�|j�r�tjd
||�|j||�EdHWn^tk
�r}z"|dk	�r�|j�|j|�WYdd}~Xq�|dk	�r,|j��Yq�XPq�Wt|�dk�rR|d�nJt|d��t�fd
d�|D���r~|d�tdjdjdd�|D�����n,|dk�r�td��t|j��s�tdj|���|j||||
�EdH\}}|j�r
|jd�}tjd|||||�||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|��kVqdS)N)r)r�rR)�modelrr�	<genexpr>sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|�VqdS)N)r)r�rRrrrr�#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rr�r�r$�setblocking�bind�errnor��strerror�lowerr`r�r	r��sock_connectr�r�allr�r+r>�_create_connection_transport�get_extra_info)rX�protocol_factoryr;r<r�r=r?rBr%r�r��f1�fs�f2�infosZladdr_infos�
exceptionsr>ZcnamerG�_ZladdrrR�	transportr�r)r�r�create_connection�s�





"




zBaseEventLoop.create_connectionc
	cs�|jd�|�}|j�}|rFt|t�r*dn|}|j||||||d�}	n|j|||�}	y|EdHWn|	j��YnX|	|fS)NF)r�r�)r�rDrrxr�r�r`)
rXr%r�r�r�r�r�rcr�r�rrrr�=s
z*BaseEventLoop._create_connection_transport)r=r?rB�
reuse_address�
reuse_port�allow_broadcastr%c#s8|
dk	r�t|
j�s tdj|
����s@�s@|s@|s@|s@|s@|s@|	r~t��||||||	d�}djdd�|j�D��}tdj|���|
jd�d}
�n*�p��s�|dkr�td	��||fdff}n�tj	�}x�d�fd
�ffD]~\}}|dk	r�t
||tj|||d�EdH}|�st
d��xB|D]:\}}}}}||f}||k�r>ddg||<||||<�qWq�W��fd
d�|j�D�}|�sztd��g}|dk�r�tjdk�o�tjdk}�x|D�]\\}}\}}d}
d}
y�tj|tj|d�}
|�r�|
jtjtjd
�|�r�t|
�|	�r|
jtjtjd
�|
jd���r,|
j|���rH|j|
|�EdH|}
Wn^t
k
�r�}z"|
dk	�rp|
j�|j|�WYdd}~Xn"|
dk	�r�|
j��YnXP�q�W|d�|�}|j�}|j|
||
|�}|j�r
��r�tjd��||�ntj d�||�y|EdHWn|j��YnX||fS)Nz#A UDP Socket was expected, got {!r})r��remote_addrr=r?rBr�r�r�z, css"|]\}}|rdj||�VqdS)z{}={}N)r�)r��k�vrrrr�isz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}�r|ddkp*�o*|ddks||f�qS)rNrr)r��keyZ	addr_pair)r�r�rrr��sz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address information�posix�cygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)!r-r>r!r��dictr��itemsr�rl�OrderedDictrKr r,r$ry�namerv�platformr"r#�SO_REUSEADDRr&ZSO_BROADCASTr�r�r`r9rDr�r�r	rIr�)rXr�r�r�r=r?rBr�r�r�r%ZoptsZproblemsZr_addrZaddr_pairs_infoZ
addr_infos�idxZaddrr�Zfamr�ZprorGrr�Z
local_addressZremote_addressrRr�rcr�r)r�r�r�create_datagram_endpointUs�








z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||d�EdH}|s0tdj|���|S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r�)rXr;r<r=rBr�rrr�_create_server_getaddrinfo�s
z(BaseEventLoop._create_server_getaddrinfor)r=rBr%�backlogr�r�r�c #s�t|t�rtd��|dk	s$�dk	�r|dk	r4td��|	dkrPtjdkoNtjdk}	g}|dkrddg}n$t|t�s|t|t	j
�r�|g}n|}����fdd�|D�}
tj|
d�i�EdH}t
tjj|��}d	}�z �x|D�]
}|\}}}}}ytj|||�}Wn6tjk
�r2�j�r,tjd
|||dd�w�YnX|j|�|	�rV|jtjtjd�|
�rdt|�t�r�|tjk�r�ttd
��r�|jtjtjd�y|j |�Wq�t!k
�r�}z t!|j"d||j#j$�f��WYdd}~Xq�Xq�Wd}Wd|�sx|D]}|j%��q�WXn2|dk�r"td��t&|j'��s<tdj(|���|g}t)�|�}x4|D],}|j*|�|j+d	��j,|||||��qRW�j�r�tj-d|�|S)Nz*ssl argument must be an SSLContext or Nonez8host/port and sock can not be specified at the same timerrr0csg|]}�j|���d��qS))r=rB)r)r�r;)r=rBr<rXrrr�sz/BaseEventLoop.create_server.<locals>.<listcomp>rHFz: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}z
%r is serving).rrxr5r!ryrrvrrrl�Iterablerr��set�	itertools�chain�
from_iterabler �errorr�r	�warningr9r"r#r	r&r8rrrZIPV6_V6ONLYr�r$r�r�r�r`r+r>r�rTZlistenr�Z_start_servingrI)rXr�r;r<r=rBr%r
r�r�r�rUZhostsr�r�Z	completed�resr@Zsocktyper?Z	canonnameZsa�errr�r)r=rBr<rXr�
create_server�s�


(





zBaseEventLoop.create_server)r�ccs^t|j�stdj|���|j|||ddd�EdH\}}|jrV|jd�}tjd|||�||fS)Nz&A Stream Socket was expected, got {!r}r0T)r�r z%r handled: (%r, %r))	r+r>r!r�r�r�r�r	r�)rXr�r%r�r�r�rrr�connect_accepted_socketAs


z%BaseEventLoop.connect_accepted_socketccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz Read pipe %r connected: (%r, %r))rDr�r`r�r	r��fileno)rXr�r�r�rcr�rrr�connect_read_pipeXszBaseEventLoop.connect_read_pipeccsd|�}|j�}|j|||�}y|EdHWn|j��YnX|jr\tjd|j�||�||fS)Nz!Write pipe %r connected: (%r, %r))rDr�r`r�r	r�r)rXr�r�r�rcr�rrr�connect_write_pipeisz BaseEventLoop.connect_write_pipecCs�|g}|dk	r |jdt|��|dk	rF|tjkrF|jdt|��n4|dk	r`|jdt|��|dk	rz|jdt|��tjdj|��dS)Nzstdin=%szstdout=stderr=%sz	stdout=%sz	stderr=%s� )r9rrrr	r�r�)rXr�r�r�r�rIrrr�_log_subprocesszszBaseEventLoop._log_subprocessT)r�r�r��universal_newlinesr�r�c
ks�t|ttf�std��|r"td��|s.td��|dkr>td��|�}
d}|jrfd|}|j||||�|j|
|d||||f|	�EdH}|jr�|dk	r�tjd||�||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr3rr!r�rr�r	rI)
rXr��cmdr�r�r�r r�r�r�r��	debug_logr�rrr�subprocess_shell�s$zBaseEventLoop.subprocess_shellcos�|rtd��|rtd��|dkr(td��|f|	}x,|D]$}t|ttf�s8tdt|�j��q8W|�}
d}|jr�d|}|j||||�|j	|
|d||||f|
�EdH}|jr�|dk	r�t
jd||�||
fS)	Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r)r!rrr3r5r>r[r�rr�r	rI)rXr�Zprogramr�r�r�r r�r�r�r�Z
popen_args�argr�r"r�rrr�subprocess_exec�s,

zBaseEventLoop.subprocess_execcCs|jS)N)rt)rXrrr�get_exception_handler�sz#BaseEventLoop.get_exception_handlercCs*|dk	r t|�r tdj|���||_dS)Nz/A callable object or None is expected, got {!r})r�r5r�rt)rXZhandlerrrr�set_exception_handler�sz#BaseEventLoop.set_exception_handlerc	Cs|jd�}|sd}|jd�}|dk	r6t|�||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}x�t|�D]�}|d
kr~qp||}|dkr�djtj|��}d}||j	�7}n2|dkr�djtj|��}d	}||j	�7}nt
|�}|jd
j||��qpWt
jdj|�|d�dS)Nr�z!Unhandled exception in event loopr�FZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z{}: {}�
)r>r�r�)r{r>�
__traceback__r}r��sortedr��	traceback�format_list�rstriprr9r�r	r)	rX�contextr�r�rZ	log_linesr�value�tbrrr�default_exception_handler�s6


z'BaseEventLoop.default_exception_handlercCs�|jdkr>y|j|�Wq�tk
r:tjddd�Yq�Xnny|j||�Wn\tk
r�}z@y|jd||d��Wn"tk
r�tjddd�YnXWYdd}~XnXdS)Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)r�r�r.zeException in default exception handler while handling an unexpected error in custom exception handler)rtr1rOr	r)rXr.rRrrrr�s"
z$BaseEventLoop.call_exception_handlercCs|jr
dS|jj|�dS)N)�
_cancelledrnr9)rXrrrr�
_add_callback9szBaseEventLoop._add_callbackcCs|j|�|j�dS)N)r3r�)rXrrrr�_add_callback_signalsafeAs
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)rori)rXrrrr�_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledcCs�t|j�}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|�q,Wtj|�||_d|_n8x6|jr�|jdjr�|jd8_tj	|j�}d|_qfWd}|j
s�|jr�d}n*|jr�|jdj}t
td||j��t�}|jo�|dk�r�|j�}|jj|�}|j�|}|dk�rtj}	ntj}	t|�}
|dk�rLtj|	d|d|
�nD|
�rntj|	d|d|d|
�n"|dk�r�tj|	d|d|d�n|jj|�}|j|�|j�|j}xD|j�r�|jd}|j|k�r�Ptj	|j�}d|_|j
j|��q�Wt|j
�}x�t|�D]|}
|j
j�}|j�r*�q|j�r�zD||_|j�}|j�|j�|}||jk�rttj d	t!|�|�Wdd|_Xn|j��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�ro�_MIN_SCHEDULED_TIMER_HANDLESri�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr2r9r��heapify�heappoprnrkZ_when�min�maxrr�MAXIMUM_SELECT_TIMEOUTr�Z	_selectorZselect�logging�INFO�DEBUGr	�logr�rs�range�popleftr}Z_runr|rr)rXZsched_countZ
new_scheduledrZtimeoutr�r�r�r��levelZneventZend_timeZntodo�irrrr�Ks�











zBaseEventLoop._run_oncecCs�ytj}tj}Wntk
r$dSXt|�}|j|kr<dStj}|�}|rz|d|fkrjtj	d|t
�q�||�d|_n,|d|fkr�tj	d|t
�n|d�d|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF)rv�set_coroutine_wrapper�get_coroutine_wrapper�AttributeErrorrxrrZ
debug_wrapperr�r��RuntimeWarning)rX�enabledZset_wrapperZget_wrapper�wrapperZcurrent_wrapperrrrr��s.

z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r�)rXrrrr��szBaseEventLoop.get_debugcCs||_|j�r|j|�dS)N)r�r�r�)rXrIrrrru�szBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)NN)F)NN)NN)Gr[rerfrYr\rDr�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rQr`r�rZPY34r�r�rrr�r�r�r�r�r�r�r�r�r�rFr�r�r�rrr r6Z
AI_PASSIVErrrrrrrr#r%r&r'r1r�r3r4r5r�r�r�rurrrrr
�s�!


		%	

u	`
12c!i�Q)1rlZconcurrent.futuresr�r��inspectrr=ryr rr�rrr+rvr�r�r0rrrrrrr@r	�__all__r6r7�BrokenPipeError�ConnectionResetError�ConnectionAbortedErrorZ_FATAL_ERROR_IGNORErr8r<rrr&r+r-rAr)rKrMrSZAbstractServerrTZAbstractEventLoopr
rrrr�<module>sT
		;


/