AlkantarClanX12

Your IP : 3.139.239.157


Current Path : /opt/alt/python35/lib64/python3.5/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/asyncio/__pycache__/base_events.cpython-35.opt-2.pyc



���]���
@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd	lmZd
gZdZdZeeefZd
d�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dddej&dddddd�Z'dd �Z(Gd!d"�d"ej)�Z*Gd#d
�d
ej+�Z,dS)$�N�)�compat)�
coroutines)�events)�futures)�tasks)�	coroutine)�logger�
BaseEventLoop�dg�?cCsH|j}tj|�r:t|jtj�r:t|j�St|�SdS)N)	�	_callback�inspectZismethod�
isinstance�__self__r�Task�repr�str)�handle�cb�r�0/opt/alt/python35/lib64/python3.5/base_events.py�_format_handle:s	$
rcCs4|tjkrdS|tjkr&dSt|�SdS)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fdrrr�_format_pipeCs
rcCs`ttd�std��n>y|jtjtjd�Wntk
r[td��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_reuseportLs
r%cCs|jtj@tjkS)N)�typer�SOCK_STREAM)r$rrr�_is_stream_socketWsr(cCs|jtj@tjkS)N)r&r�
SOCK_DGRAM)r$rrr�_is_dgram_socket^sr*cCs�ttd�sdS|dtjtjhks:|dkr>dS|tjkrYtj}n|tjkrttj}ndS|dkr�d}nwt|t�r�|dkr�d}nSt|t�r�|dkr�d}n/yt	|�}Wnt
tfk
rdSYnX|tjkrAtj
g}ttd�rJ|jtj�n	|g}t|t�rh|jd�}d|krxdSxP|D]H}y-tj||�|||d||ffSWqtk
r�YqXqWdS)N�	inet_ptonr���AF_INET6Zidna�%)rr�IPPROTO_TCP�IPPROTO_UDPr'r)r�bytesr�int�	TypeErrorr �	AF_UNSPEC�AF_INET�appendr.�decoder+r#)�host�port�familyr&�protoZafs�afrrr�_ipaddr_infoesH					

	r>r;r&r<�flagsc
Cs�|dd�\}}t|||||�}|dk	rZ|j�}	|	j|g�|	S|j||d|d|d|d|�SdS)N�r;r&r<r?)r>�
create_future�
set_result�getaddrinfo)
�addressr;r&r<r?�loopr9r:�info�futrrr�_ensure_resolved�srHcCs=|j}t|t�r,t|t�r,dS|jj�dS)N)�
_exceptionr�
BaseException�	Exception�_loop�stop)rG�excrrr�_run_until_complete_cb�s
	rOc@sjeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
dS)�ServercCs(||_||_d|_g|_dS)Nr)rL�sockets�
_active_count�_waiters)�selfrErQrrr�__init__�s			zServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>)�	__class__�__name__rQ)rTrrr�__repr__�szServer.__repr__cCs|jd7_dS)Nr)rR)rTrrr�_attach�szServer._attachcCs;|jd8_|jdkr7|jdkr7|j�dS)Nrr)rRrQ�_wakeup)rTrrr�_detach�szServer._detachcCs`|j}|dkrdSd|_x|D]}|jj|�q)W|jdkr\|j�dS)Nr)rQrLZ
_stop_servingrRrZ)rTrQr$rrr�close�s		
zServer.closecCs@|j}d|_x'|D]}|j�s|j|�qWdS)N)rS�donerB)rT�waiters�waiterrrrrZ�s
		
zServer._wakeupccsN|jdks|jdkr"dS|jj�}|jj|�|EdHdS)N)rQrSrLrAr7)rTr_rrr�wait_closed�s
zServer.wait_closedN)rW�
__module__�__qualname__rUrXrYr[r\rZrr`rrrrrP�s
rPc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
dd
dd
dd�Z	d
dddd
dd
dd
dd�Z
d
d
d
dd�Zd
d
dd�Zd
d
dd�Z
ed
dd��Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zed)d*��Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zejr�d5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdPdQdPdRdPdSdPdTdU�Z*dPdVdW�Z+ed
d
dXd
dOdPdRdPdSdPdYd
dZd
dd
d[d\��Z,edd]d^��Z-ed
d
dOdPdRdPdSdPd_d
d`d
dad
dYd
dbdc��Z.eddde��Z/ed
d
dOe0j1dSe0j2dYd
dfdgdXd
d_d
d`d
dhdi��Z3edXd
djdk��Z4edldm��Z5edndo��Z6dpdq�Z7edre8j9dse8j9dte8j9duddvdwdxdPdydz��Z:edre8j9dse8j9dte8j9duddvddxdPd{d|��Z;d}d~�Z<dd��Z=d�d��Z>d�d��Z?d�d��Z@d�d��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o�ttjjd���d|_d|_d|_d|_ttd�r�tj�|_n	d|_d|_dS)NrF�	monotonicZPYTHONASYNCIODEBUGg�������?�get_asyncgen_hooks) �_timer_cancelled_count�_closed�	_stopping�collections�deque�_ready�
_scheduled�_default_executorZ
_internal_fds�
_thread_id�time�get_clock_infoZ
resolution�_clock_resolution�_exception_handler�	set_debug�sysr?�ignore_environment�bool�os�environ�get�slow_callback_duration�_current_handle�
_task_factory�_coroutine_wrapper_setr�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called)rTrrrrU�s(													zBaseEventLoop.__init__cCs,d|jj|j�|j�|j�fS)Nz"<%s running=%s closed=%s debug=%s>)rVrW�
is_running�	is_closed�	get_debug)rTrrrrXszBaseEventLoop.__repr__cCstjd|�S)NrE)r�Future)rTrrrrAszBaseEventLoop.create_futurecCsZ|j�|jdkrDtj|d|�}|jrV|jd=n|j||�}|S)NrEr���)�
_check_closedr{rr�_source_traceback)rT�coroZtaskrrr�create_tasks
	
zBaseEventLoop.create_taskcCs2|dk	r%t|�r%td��||_dS)Nz'task factory must be a callable or None)�callabler4r{)rT�factoryrrr�set_task_factory#s
zBaseEventLoop.set_task_factorycCs|jS)N)r{)rTrrr�get_task_factory1szBaseEventLoop.get_task_factoryN�extra�servercCs
t�dS)N)�NotImplementedError)rTr$�protocolr_r�r�rrr�_make_socket_transport5sz$BaseEventLoop._make_socket_transport�server_sideF�server_hostnamec	Cs
t�dS)N)r�)	rTZrawsockr��
sslcontextr_r�r�r�r�rrr�_make_ssl_transport:sz!BaseEventLoop._make_ssl_transportcCs
t�dS)N)r�)rTr$r�rDr_r�rrr�_make_datagram_transport@sz&BaseEventLoop._make_datagram_transportcCs
t�dS)N)r�)rT�piper�r_r�rrr�_make_read_pipe_transportEsz'BaseEventLoop._make_read_pipe_transportcCs
t�dS)N)r�)rTr�r�r_r�rrr�_make_write_pipe_transportJsz(BaseEventLoop._make_write_pipe_transportc	
Ks
t�dS)N)r�)
rTr��args�shell�stdin�stdout�stderr�bufsizer��kwargsrrr�_make_subprocess_transportOsz(BaseEventLoop._make_subprocess_transportcCs
t�dS)N)r�)rTrrr�_write_to_selfVszBaseEventLoop._write_to_selfcCs
t�dS)N)r�)rT�
event_listrrr�_process_events_szBaseEventLoop._process_eventscCs|jrtd��dS)NzEvent loop is closed)rf�RuntimeError)rTrrrr�cs	zBaseEventLoop._check_closedcCs=|jj|�|j�s9|j|j��|j�dS)N)r�discardr�r��acloser�)rT�agenrrr�_asyncgen_finalizer_hookgsz&BaseEventLoop._asyncgen_finalizer_hookcCs<|jr(tjdj|�td|�|jj|�dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call�source)r��warnings�warn�format�ResourceWarningr�add)rTr�rrr�_asyncgen_firstiter_hookos	
z&BaseEventLoop._asyncgen_firstiter_hookccs�d|_|jdks(t|j�r,dSt|j�}|jj�tjdd�|D�ddd|�}|EdH}xTt||�D]C\}}t|t	�r�|j
ddj|�d|d	|i�q�WdS)
NTcSsg|]}|j��qSr)r�)�.0Zagrrr�
<listcomp>�s	z4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>Zreturn_exceptionsrE�messagez?an error occurred during closing of asynchronous generator {!r}�	exceptionZasyncgen)r�r�len�list�clearr�gather�ziprrK�call_exception_handlerr�)rTZ
closing_agensZ
shutdown_coro�results�resultr�rrr�shutdown_asyncgensxs"	
		z BaseEventLoop.shutdown_asyncgenscCs|j�|j�r"td��tj�dk	r@td��|j|j�tj�|_	|j
dk	r�tj�}tj
d|jd|j�z,tj|�x|j�|jr�Pq�WWdd|_d|_	tjd�|jd�|j
dk	r
tj
|�XdS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is runningZ	firstiter�	finalizerF)r�r�r�rZ_get_running_loop�_set_coroutine_wrapper�_debug�	threading�	get_identrmrrsrdZset_asyncgen_hooksr�r�Z_set_running_loop�	_run_oncerg)rTZold_agen_hooksrrr�run_forever�s0
	


				

zBaseEventLoop.run_forevercCs�|j�tj|�}tj|d|�}|r>d|_|jt�zIy|j�Wn4|r�|j	�r�|j
�r�|j��YnXWd|jt�X|j	�s�t
d��|j�S)NrEFz+Event loop stopped before Future completed.)r�rZisfuturerZ
ensure_futureZ_log_destroy_pending�add_done_callbackrOr�r]�	cancelledr�Zremove_done_callbackr�r�)rT�futureZnew_taskrrr�run_until_complete�s 
	

z BaseEventLoop.run_until_completecCs
d|_dS)NT)rg)rTrrrrM�szBaseEventLoop.stopcCs�|j�rtd��|jr%dS|jr>tjd|�d|_|jj�|jj�|j	}|dk	r�d|_	|j
dd�dS)Nz!Cannot close a running event loopzClose %rT�waitF)r�r�rfr�r	�debugrjr�rkrl�shutdown)rT�executorrrrr\�s			

		zBaseEventLoop.closecCs|jS)N)rf)rTrrrr��szBaseEventLoop.is_closedcCs:|j�s6tjd|t�|j�s6|j�dS)Nzunclosed event loop %r)r�r�r�r�r�r\)rTrrr�__del__�szBaseEventLoop.__del__cCs
|jdk	S)N)rm)rTrrrr�szBaseEventLoop.is_runningcCs
tj�S)N)rnrc)rTrrrrnszBaseEventLoop.timecGs6|j|j�|||�}|jr2|jd=|S)Nrr�)�call_atrnr�)rT�delay�callbackr��timerrrr�
call_laters	
zBaseEventLoop.call_latercGsx|j�|jr-|j�|j|d�tj||||�}|jrX|jd=tj|j	|�d|_	|S)Nr�rTr�)
r�r��
_check_thread�_check_callbackrZTimerHandler��heapq�heappushrk)rT�whenr�r�r�rrrr�#s
	
	
	zBaseEventLoop.call_atcGsV|j�|jr-|j�|j|d�|j||�}|jrR|jd=|S)N�	call_soonrr�)r�r�r�r��
_call_soonr�)rTr�r�rrrrr�3s

	
	
zBaseEventLoop.call_sooncCs[tj|�stj|�r3tdj|���t|�sWtdj||���dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZiscoroutineZiscoroutinefunctionr4r�r�)rTr��methodrrrr�FszBaseEventLoop._check_callbackcCs<tj|||�}|jr(|jd=|jj|�|S)Nrr�)rZHandler�rjr7)rTr�r�rrrrr�Qs
	
zBaseEventLoop._call_sooncCs>|jdkrdStj�}||jkr:td��dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rmr�r�r�)rTZ	thread_idrrrr�Xs	zBaseEventLoop._check_threadcGsV|j�|jr#|j|d�|j||�}|jrH|jd=|j�|S)N�call_soon_threadsaferr�)r�r�r�r�r�r�)rTr�r�rrrrr�is
		

z"BaseEventLoop.call_soon_threadsafecGs{|j�|jr#|j|d�|dkr\|j}|dkr\tjj�}||_tj|j||�d|�S)N�run_in_executorrE)	r�r�r�rl�
concurrentr�ThreadPoolExecutorZwrap_future�submit)rTr��funcr�rrrr�ts
			zBaseEventLoop.run_in_executorcCs
||_dS)N)rl)rTr�rrr�set_default_executorsz"BaseEventLoop.set_default_executorcCsd||fg}|r*|jd|�|rA|jd|�|rX|jd|�|ro|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@�@)	r7�joinr	r�rnrrCryrF)rTr9r:r;r&r<r?�msg�t0Zaddrinfo�dtrrr�_getaddrinfo_debug�s(
z BaseEventLoop._getaddrinfo_debugr;rr&r<r?c	CsW|jr.|jd|j||||||�S|jdtj||||||�SdS)N)r�r�r�rrC)rTr9r:r;r&r<r?rrrrC�s
	zBaseEventLoop.getaddrinfocCs|jdtj||�S)N)r�r�getnameinfo)rTZsockaddrr?rrrr��szBaseEventLoop.getnameinfo�sslr$�
local_addrc#s#|
dk	r|rtd��|
dkrI|rI|sCtd��|}
|dk	sa|dk	r�|dk	rytd��t||fd|dtjd|d|d|�}|g}|	dk	r�t|	d|dtjd|d|d|�}
|j|
�nd}
tj|d|�EdH|j�}|s:td	��|
dk	rd|
j�}|sdtd	��g}xU|D]�\}}}}}y
tjd|d|d|�}|j	d
�|
dk	rax�|D]�\}}}}}y|j
|�PWq�tk
rI}z9t|jdj||j
j���}|j|�WYdd}~Xq�Xq�W|j�d}wq|jr}tjd||�|j||�EdHWnhtk
r�}z(|dk	r�|j�|j|�WYdd}~Xqq|dk	r�|j��YqqXPqqWt|�d
kr"|d�q�t|d��t�fdd�|D��r[|d�tdjdjdd�|D�����n9|dkr�td��t|�s�tdj|���|j||||
�EdH\}}|jr|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 timer;r&r<r?rEz!getaddrinfo() returned empty listFz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s!|]}t|��kVqdS)N)r)r�rN)�modelrr�	<genexpr>sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|�VqdS)N)r)r�rNrrrr�sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}rz%r connected to %s:%r: (%r, %r))r rHrr'r7rr�r�r#�setblocking�bind�errnor��strerror�lowerr\r�r	r��sock_connectr�r�allr�r(�_create_connection_transport�get_extra_info)rT�protocol_factoryr9r:r�r;r<r?r$r�r��f1�fs�f2�infosZladdr_infos�
exceptionsr&ZcnamerD�_�laddrrN�	transportr�r)r�r�create_connection�s�		

$
	



	%			zBaseEventLoop.create_connectionc
	cs�|jd�|�}|j�}|rjt|t�r=dn|}|j||||d|d|�}	n|j|||�}	y
|EdHWn|	j��YnX|	|fS)NFr�r�)r�rArrur�r�r\)
rTr$r�r�r�r�r�r_r�r�rrrr�+s
	

z*BaseEventLoop._create_connection_transport�
reuse_address�
reuse_port�allow_broadcastc#sT|
dk	r�t|
�s-tdj|
����s]�s]|s]|s]|s]|s]|s]|	r�td�d�d|d|d|d|d|d	|	�}d
jdd�|j�D��}td
j|���|
jd�d}
n��p��s|dkrtd��||fdff}ntj�}x�d�fd�ffD]�\}}|dk	rDt	|d|dt
jd|d|d|�EdH}|s�td��xS|D]K\}}}}}||f}||kr�ddg||<||||<q�WqDW��fdd�|j�D�}|s.td��g}|dkr^t
jdko[tjdk}xV|D]D\\}}\}}d}
d}
y�t
j
d|dt
jd|�}
|r�|
jt
jt
jd�|r�t|
�|	r�|
jt
jt
jd�|
jd��r|
j|��r<|j|
|�EdH|}
Wnhtk
r�}z(|
dk	rh|
j�|j|�WYdd}~Xqe|
dk	r�|
j��YqeXPqeW|d�|�}|j�}|j|
||
|�}|jr%�rtjd��||�ntjd�||�y
|EdHWn|j��YnX||fS)Nz#A UDP Socket was expected, got {!r}r��remote_addrr;r<r?rrrz, css-|]#\}}|rdj||�VqdS)z{}={}N)r�)r��k�vrrrr�Wsz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrr&rEz!getaddrinfo() returned empty listcsNg|]D\}}�r(|ddkp;�o;|ddks||f�qS)rNrr)r��keyZ	addr_pair)r�rrrr�xs		z:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address information�posix�cygwinz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r*r r��dictr��itemsr�rh�OrderedDictrHrr)r#rv�namers�platformr!r"�SO_REUSEADDRr%�SO_BROADCASTr�r�r\r7rAr�r�r	rFr�)rTr�r�rr;r<r?rrrr$ZoptsZproblemsZr_addrZaddr_pairs_infoZ
addr_infos�idx�addrr�Zfamr�ZprorDrr�Z
local_addressZremote_addressrNr�r_r�r)r�rr�create_datagram_endpointCs�	
	%"	






				


z&BaseEventLoop.create_datagram_endpointc
csQt||fd|dtjd|d|�EdH}|sMtdj|���|S)Nr;r&r?rEz%getaddrinfo({!r}) returned empty list)rHrr'r#r�)rTr9r:r;r?r�rrr�_create_server_getaddrinfo�s	z(BaseEventLoop._create_server_getaddrinfo�backlogrc #sdt|t�rtd��|dk	s3�dk	r�|dk	rKtd��ttdd�}|	dkr�tjdko�tj	dk}	g}|dkr�dg}
n4t|t
�s�t|tj�r�|g}
n|}
����fdd	�|
D�}t
j|d
��EdH}ttjj|��}d}zWxJ|D]B}|\}}}}}ytj|||�}Wn=tjk
r��jr�tjd|||d
d�w=YnX|j|�|	r�|jtjtjd�|
r�t|�||kr!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�WXnB|dkr�td��t%|�s�tdj&|���|g}t'�|�}xA|D]9}|j(|�|j)d��j*|||||�q
W�jr`tj+d|�|S)Nz*ssl argument must be an SSLContext or Nonez8host/port and sock can not be specified at the same timer.rrrr-c	s.g|]$}�j|�d�d���qS)r;r?)r)r�r9)r;r?r:rTrrr��s	z/BaseEventLoop.create_server.<locals>.<listcomp>rEFz:create_server() failed to create socket.socket(%r, %r, %r)�exc_infoT�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),rrur4r �getattrrrvrrsr
rrh�Iterablerr��set�	itertools�chain�
from_iterable�errorr�r	�warningr7r!r"rr%rr�IPV6_V6ONLYr�r#r�r�r�r\r(r�rP�listenr�Z_start_servingrF)rTr�r9r:r;r?r$rr�rrr.rQZhostsr�r�Z	completed�resr=�socktyper<�	canonname�sa�errr�r)r;r?r:rTr�
create_server�s�	

		

0

	


	zBaseEventLoop.create_serverccs�t|�s!tdj|���|j|||ddd�EdH\}}|jrx|jd�}tjd|||�||fS)Nz&A Stream Socket was expected, got {!r}r-r�Trz%r handled: (%r, %r))r(r r�r�r�r�r	r�)rTr�r$r�r�r�rrr�connect_accepted_socket.s
#	z%BaseEventLoop.connect_accepted_socketccs~|�}|j�}|j|||�}y
|EdHWn|j��YnX|jrttjd|j�||�||fS)Nz Read pipe %r connected: (%r, %r))rAr�r\r�r	r��fileno)rTr�r�r�r_r�rrr�connect_read_pipeEs	

		zBaseEventLoop.connect_read_pipeccs~|�}|j�}|j|||�}y
|EdHWn|j��YnX|jrttjd|j�||�||fS)Nz!Write pipe %r connected: (%r, %r))rAr�r\r�r	r�r()rTr�r�r�r_r�rrr�connect_write_pipeVs	

		z BaseEventLoop.connect_write_pipecCs�|g}|dk	r,|jdt|��|dk	ra|tjkra|jdt|��nF|dk	r�|jdt|��|dk	r�|jdt|��tjdj|��dS)Nzstdin=%szstdout=stderr=%sz	stdout=%sz	stderr=%s� )r7rrrr	r�r�)rTr�r�r�r�rFrrr�_log_subprocessgs	zBaseEventLoop._log_subprocessr�r�r��universal_newlinesr�Tr�c
	ks�t|ttf�s!td��|r3td��|sEtd��|dkr]td��|�}
|jr�d|}|j||||�|j|
|d|||||	�EdH}|jr�tjd||�||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr2rr r�r,r�r	rF)
rTr��cmdr�r�r�r-r�r�r�r��	debug_logr�rrr�subprocess_shellts"		
#	zBaseEventLoop.subprocess_shellc	os	|rtd��|r$td��|dkr<td��|f|	}x<|D]4}t|ttf�sPtdt|�j��qPW|�}
|jr�d|}|j||||�|j	|
|d|||||
�EdH}|jr�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 rrr2r4r&rWr�r,r�r	rF)rTr�Zprogramr�r�r�r-r�r�r�r�Z
popen_args�argr�r/r�rrr�subprocess_exec�s*

		
	zBaseEventLoop.subprocess_execcCs|jS)N)rq)rTrrr�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�r4r�rq)rT�handlerrrr�set_exception_handler�s	z#BaseEventLoop.set_exception_handlerc	Cs�|jd�}|sd}|jd�}|dk	rQt|�||jf}nd}d|kr�|jdk	r�|jjr�|jj|d<|g}x�t|�D]�}|d
kr�q�||}|dkrdjtj|��}d}||j	�7}nI|dkr=djtj|��}d	}||j	�7}nt
|�}|jd
j||��q�Wt
jdj|�d|�dS)Nr�z!Unhandled exception in event loopr�FZsource_tracebackZhandle_tracebackr-z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z{}: {}�
r>r�r�)rxr&�
__traceback__rzr��sortedr��	traceback�format_list�rstriprr7r�r	r)	rT�contextr�r�rZ	log_linesr�value�tbrrr�default_exception_handler�s6
	
z'BaseEventLoop.default_exception_handlercCs�|jdkrKy|j|�Wq�tk
rGtjddd�Yq�Xn�y|j||�Wnptk
r�}zPy#|jddd|d|i�Wn%tk
r�tjddd�YnXWYdd}~XnXdS)	Nz&Exception in default exception handlerrTr�z$Unhandled error in exception handlerr�r<zeException in default exception handler while handling an unexpected error in custom exception handler)rqr?rKr	r)rTr<rNrrrr��s"

z$BaseEventLoop.call_exception_handlercCs!|jr
dS|jj|�dS)N)�
_cancelledrjr7)rTrrrr�
_add_callbacks	zBaseEventLoop._add_callbackcCs|j|�|j�dS)N)rAr�)rTrrrr�_add_callback_signalsafe's
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)rkre)rTrrrr�_timer_handle_cancelled,s	z%BaseEventLoop._timer_handle_cancelledcCslt|j�}|tkr�|j|tkr�g}x3|jD](}|jrYd|_q>|j|�q>Wtj|�||_d|_nJxG|jr�|jdjr�|jd8_tj	|j�}d|_q�Wd}|j
s�|jr�d}n2|jr)|jdj}t
d||j��}|jr|dkr|j�}|jj|�}|j�|}|dkr�tj}	n	tj}	t|�}
|dkr�tj|	d|d|
�q+|
r�tj|	d|d|d|
�q+|dkr+tj|	d|d|d�n|jj|�}|j|�|j�|j}xU|jr�|jd}|j|krtPtj	|j�}d|_|j
j|�qNWt|j
�}x�t|�D]�}
|j
j�}|jr�q�|jrTz[||_|j�}|j�|j�|}||jkrCtjd	t|�|�Wdd|_Xq�|j�q�Wd}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�rk�_MIN_SCHEDULED_TIMER_HANDLESre�%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr@r7r��heapify�heappoprjrgZ_when�maxrnr��	_selector�select�logging�INFO�DEBUGr	�logr�rp�range�popleftrzZ_runryrr)rTZsched_countZ
new_scheduledr�timeoutr�r�r�r��levelZnevent�end_timeZntodo�irrrr�1s�
		
	
					

				
	
zBaseEventLoop._run_oncecCs�ytj}tj}Wntk
r.dSYnXt|�}|j|krNdStj}|�}|r�|d|fkr�tj	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)rs�set_coroutine_wrapper�get_coroutine_wrapper�AttributeErrorrur|rZ
debug_wrapperr�r��RuntimeWarning)rT�enabledZset_wrapperZget_wrapper�wrapperZcurrent_wrapperrrrr��s.	

			

z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r�)rTrrrr��szBaseEventLoop.get_debugcCs&||_|j�r"|j|�dS)N)r�r�r�)rTrYrrrrr�s	zBaseEventLoop.set_debug)GrWrarbrUrXrAr�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rMr\r�rZPY34r�r�rnr�r�r�r�r�r�r�r�r�r�rCr�r�r�rrrr5�
AI_PASSIVEr&r'r)r*r,rrr0r2r3r5r?r�rArBrCr�r�r�rrrrrrr
�s�!		%		!	�	u				_
	,2c!)-rh�concurrent.futuresr�r�r
rrKrvrrr�rnr9rsr�r}r-rrrrrrrNr	�__all__rDrE�BrokenPipeError�ConnectionResetError�ConnectionAbortedErrorZ_FATAL_ERROR_IGNORErrr%r(r*r>r'rHrOZAbstractServerrPZAbstractEventLoopr
rrrr�<module>sJ			=

/