Your IP : 3.22.42.25


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



���]�D�@sHddddddgZddlZddlZddlZddlZddlZdd	lmZdd
lm	Z	dZ
dZd
Zej
jjZej
jZej
jZejdZGdd�de�ZGdd�d�Zdd�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdddd�ZdS)�CancelledError�TimeoutError�InvalidStateError�Future�wrap_future�isfuture�N�)�compat)�events�PENDING�	CANCELLED�FINISHEDc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�,/opt/alt/python35/lib64/python3.5/futures.pyrsc@sFeZdZdZdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracebackLogger�loop�source_traceback�exc�tbcCs.|j|_|j|_||_d|_dS)N)�_loopr�_source_tracebackrrr)�self�futurerrrr�__init__Us	z_TracebackLogger.__init__cCs@|j}|dk	r<d|_tj|j||j�|_dS)N)r�	traceback�format_exception�	__class__�
__traceback__r)rrrrr�activate[s
		z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrr�clearbs	z_TracebackLogger.clearcCs�|jr�d}|jrQdjtj|j��}|d7}|d|j�7}|dj|j�j�7}|jjd|i�dS)Nz*Future/Task exception was never retrieved
�z0Future/Task created at (most recent call last):
z%s
�message)rr�joinr�format_list�rstripr�call_exception_handler)r�msg�srcrrr�__del__fs		
z_TracebackLogger.__del__N)rrrr)rrr�	__slots__rr!r"r+rrrrr!s
2rcCst|jd�o|jdk	S)N�_asyncio_future_blocking)�hasattrrr-)�objrrrrqsc@seZdZeZdZdZdZdZdZ	dZ
dZdddd�Zdd�Z
dd	�Zd
d�Zejr�dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZejreZdS)$rNFrcCs^|dkrtj�|_n	||_g|_|jj�rZtjtjd��|_	dS)Nr)
r
�get_event_loopr�
_callbacksZ	get_debugr�
extract_stack�sys�	_getframer)rrrrrr�s		zFuture.__init__cCs�|j}t|�}|s!d}dd�}|dkrL||d�}nn|dkr�dj||d�||d��}n9|dkr�dj||d�|d||d
��}d	|S)Nr#cSstj|f�S)N)r
Z_format_callback_source)�callbackrrr�	format_cb�sz,Future.__format_callbacks.<locals>.format_cbrr�z{}, {}z{}, <{} more>, {}zcb=[%s]���)r1�len�format)r�cb�sizer6rrrZ__format_callbacks�s	)zFuture.__format_callbackscCs�|jj�g}|jtkrt|jdk	rL|jdj|j��n(tj|j�}|jdj|��|j	r�|j|j
��|jr�|jd}|jd|d|df�|S)Nzexception={!r}z	result={}rzcreated at %s:%srr8)�_state�lower�	_FINISHED�
_exception�appendr:�reprlib�repr�_resultr1�_Future__format_callbacksr)r�info�result�framerrr�
_repr_info�s		
zFuture._repr_infocCs)|j�}d|jjdj|�fS)Nz<%s %s>� )rIrrr%)rrFrrr�__repr__�szFuture.__repr__cCsb|js
dS|j}dd|jjd|d|i}|jrN|j|d<|jj|�dS)Nr$z %s exception was never retrieved�	exceptionrr)�_log_tracebackr@rrrrr()rr�contextrrrr+�s		
	
zFuture.__del__cCs3d|_|jtkrdSt|_|j�dS)NFT)rMr=�_PENDING�
_CANCELLED�_schedule_callbacks)rrrr�cancel�s		
z
Future.cancelcCsX|jdd�}|sdSg|jdd�<x!|D]}|jj||�q7WdS)N)r1r�	call_soon)rZ	callbacksr5rrrrQ�s
zFuture._schedule_callbackscCs
|jtkS)N)r=rP)rrrr�	cancelledszFuture.cancelledcCs
|jtkS)N)r=rO)rrrr�doneszFuture.donecCs}|jtkrt�|jtkr0td��d|_|jdk	r^|jj�d|_|jdk	rv|j�|j	S)NzResult is not ready.F)
r=rPrr?rrM�
_tb_loggerr"r@rD)rrrrrGs	
		z
Future.resultcCse|jtkrt�|jtkr0td��d|_|jdk	r^|jj�d|_|jS)NzException is not set.F)	r=rPrr?rrMrVr"r@)rrrrrL)s	
	zFuture.exceptioncCs9|jtkr%|jj||�n|jj|�dS)N)r=rOrrSr1rA)r�fnrrr�add_done_callback;szFuture.add_done_callbackcsR�fdd�|jD�}t|j�t|�}|rN||jdd�<|S)Ncs"g|]}|�kr|�qSrr)�.0�f)rWrr�
<listcomp>Ns	z/Future.remove_done_callback.<locals>.<listcomp>)r1r9)rrWZfiltered_callbacksZ
removed_countr)rWr�remove_done_callbackIs
zFuture.remove_done_callbackcCsJ|jtkr*tdj|j|���||_t|_|j�dS)Nz{}: {!r})r=rOrr:rDr?rQ)rrGrrr�
set_resultVs
		zFuture.set_resultcCs�|jtkr*tdj|j|���t|t�rB|�}t|�tkr`td��||_t	|_|j
�tjr�d|_
n(t||�|_|jj|jj�dS)Nz{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureT)r=rOrr:�
isinstance�type�
StopIteration�	TypeErrorr@r?rQr	�PY34rMrrVrrSr!)rrLrrr�
set_exceptionbs			
	zFuture.set_exceptionccs$|j�sd|_|V|j�S)NT)rUr-rG)rrrr�__iter__zs	zFuture.__iter__) rrrrOr=rDr@rrr-rMrVrrErIrKr	rbr+rRrQrTrUrGrLrXr\r]rcrdZPY35�	__await__rrrrr|s6
	
	cCs!|j�rdS|j|�dS)N)rTr])ZfutrGrrr�_set_result_unless_cancelled�srfcCsk|j�r|j�|j�s&dS|j�}|dk	rN|j|�n|j�}|j|�dS)N)rTrR�set_running_or_notify_cancelrLrcrGr])�
concurrent�sourcerLrGrrr�_set_concurrent_future_state�s
rjcCsn|j�rdS|j�r)|j�nA|j�}|dk	rQ|j|�n|j�}|j|�dS)N)rTrRrLrcrGr])ri�destrLrGrrr�_copy_future_state�s
rlcs�t��r/t�tjj�r/td��t��r^t�tjj�r^td��t��rs�jnd�t��r��jnd�dd�����fdd�}����fdd�}�j|��j|�dS)	Nz(A future is required for source argumentz-A future is required for destination argumentcSs-t|�rt||�n
t||�dS)N)rrlrj)r�otherrrr�
_set_state�sz!_chain_future.<locals>._set_statecsE|j�rA�dks$��kr1�j�n�j�j�dS)N)rTrR�call_soon_threadsafe)�destination)�	dest_loopri�source_looprr�_call_check_cancel�s
z)_chain_future.<locals>._call_check_cancelcs?�dks��kr(��|�n�j��|�dS)N)ro)ri)rnrqrprrrr�_call_set_state�sz&_chain_future.<locals>._call_set_state)rr^rh�futuresrrarrX)rirprsrtr)rnrqrprirrr�
_chain_future�s
rvrcCsEt|�r|S|dkr(tj�}|j�}t||�|S)N)rr
r0Z
create_futurerv)rrZ
new_futurerrrr�s
)�__all__�concurrent.futures._baserh�loggingrBr3rr#r	r
rOrPr?ru�_base�Errorrr�DEBUGZSTACK_DEBUGrrrrrfrjrlrvrrrrr�<module>s4
P�
'

?>