Your IP : 13.59.69.109


Current Path : /opt/alt/python39/lib64/python3.9/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/asyncio/__pycache__/futures.cpython-39.opt-2.pyc

a

R�f�6�@sdZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZe	j
Z
e	jZe	jZe	jZejdZGd	d
�d
�ZeZdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�dd�ZzddlZWney�Yn0ejZZdS))�Future�wrap_future�isfuture�N)�GenericAlias�)�base_futures)�events)�
exceptions)�format_helpersc@s�eZdZeZdZdZdZdZdZ	dZ
dZdZdd�dd�Z
ejZdd�Zdd	�Zee�Zed
d��Zejdd��Zd
d�Zdd�Zd(dd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�dd�Z!d d!�Z"d"d#�Z#d$d%�Z$d&d'�Z%e%Z&dS))rNF��loopcCs@|durt��|_n||_g|_|j��r<t�t�d��|_	dS)Nr)
r�get_event_loop�_loop�
_callbacksZ	get_debugr
�
extract_stack�sys�	_getframe�_source_traceback��selfr�r�4/opt/alt/python39/lib64/python3.9/asyncio/futures.py�__init__Hs
�zFuture.__init__cCsd�|jjd�|����S)Nz<{} {}>� )�format�	__class__�__name__�join�
_repr_info�rrrr�__repr__Zs
�zFuture.__repr__cCsF|js
dS|j}|jj�d�||d�}|jr6|j|d<|j�|�dS)Nz exception was never retrieved)�message�	exception�futureZsource_traceback)�_Future__log_traceback�
_exceptionrrrrZcall_exception_handler)r�exc�contextrrr�__del__^s�
zFuture.__del__cCs|jS�N)r$rrrr�_log_tracebackpszFuture._log_tracebackcCst|�rtd��d|_dS)Nz'_log_traceback can only be set to FalseF)�bool�
ValueErrorr$)r�valrrrr*tscCs|j}|durtd��|S)Nz!Future object is not initialized.)r�RuntimeErrorrrrr�get_loopzszFuture.get_loopcCs2|jdurt��}nt�|j�}|j|_d|_|Sr))�_cancel_messager	�CancelledError�_cancelled_exc�__context__�rr&rrr�_make_cancelled_error�s

zFuture._make_cancelled_errorcCs,d|_|jtkrdSt|_||_|��dS)NFT)r$�_state�_PENDING�
_CANCELLEDr0�_Future__schedule_callbacks)r�msgrrr�cancel�s
z
Future.cancelcCsH|jdd�}|sdSg|jdd�<|D]\}}|jj|||d�q(dS�N�r')rr�	call_soon)rZ	callbacks�callback�ctxrrrZ__schedule_callbacks�szFuture.__schedule_callbackscCs
|jtkSr))r6r8rrrr�	cancelled�szFuture.cancelledcCs
|jtkSr))r6r7rrrr�done�szFuture.donecCsF|jtkr|��}|�|jtkr*t�d��d|_|jdur@|j�|jS)NzResult is not ready.F)	r6r8r5�	_FINISHEDr	�InvalidStateErrorr$r%�_resultr4rrr�result�s



z
Future.resultcCs6|jtkr|��}|�|jtkr*t�d��d|_|jS)NzException is not set.F)r6r8r5rCr	rDr$r%r4rrrr"�s


zFuture.exceptionr=cCsB|jtkr|jj|||d�n |dur.t��}|j�||f�dSr<)r6r7rr>�contextvarsZcopy_contextr�append)r�fnr'rrr�add_done_callback�s

zFuture.add_done_callbackcs<�fdd�|jD�}t|j�t|�}|r8||jdd�<|S)Ncs g|]\}}|�kr||f�qSrr)�.0�fr@�rIrr�
<listcomp>�s�z/Future.remove_done_callback.<locals>.<listcomp>)r�len)rrIZfiltered_callbacksZ
removed_countrrMr�remove_done_callback�s
�zFuture.remove_done_callbackcCs8|jtkr t�|j�d|����||_t|_|��dS)N�: )r6r7r	rDrErCr9)rrFrrr�
set_result�s

zFuture.set_resultcCsb|jtkr t�|j�d|����t|t�r0|�}t|�turDtd��||_t	|_|�
�d|_dS)NrQzPStopIteration interacts badly with generators and cannot be raised into a FutureT)r6r7r	rD�
isinstance�type�
StopIteration�	TypeErrorr%rCr9r$)rr"rrr�
set_exceptions

zFuture.set_exceptionccs,|��sd|_|V|��s$td��|��S)NTzawait wasn't used with future)rB�_asyncio_future_blockingr.rFrrrr�	__await__szFuture.__await__)N)'r�
__module__�__qualname__r7r6rEr%rrr0r2rXr$rrZ_future_repr_inforr r(�classmethodr�__class_getitem__�propertyr*�setterr/r5r;r9rArBrFr"rJrPrRrWrY�__iter__rrrrrs@


rcCs*z
|j}WntyYn0|�S|jSr))r/�AttributeErrorr)�futr/rrr�	_get_loop(s
rccCs|��rdS|�|�dSr))rArR)rbrFrrr�_set_result_unless_cancelled4srdcCsXt|�}|tjjur tj|j�S|tjjur8tj|j�S|tjjurPtj|j�S|SdSr))rT�
concurrent�futuresr1r	�args�TimeoutErrorrD)r&Z	exc_classrrr�_convert_future_exc;sricCsR|��r|��|��sdS|��}|dur<|�t|��n|��}|�|�dSr))rAr;Zset_running_or_notify_cancelr"rWrirFrR)re�sourcer"rFrrr�_set_concurrent_future_stateGsrkcCsT|��rdS|��r|��n2|��}|dur>|�t|��n|��}|�|�dSr))rAr;r"rWrirFrR)rj�destr"rFrrr�_copy_future_stateVs
rmcs�t��st�tjj�std��t��s<t�tjj�s<td��t��rLt��nd�t��r`t��nd�dd�����fdd�}����fdd�}��|���|�dS)	Nz(A future is required for source argumentz-A future is required for destination argumentcSs"t|�rt||�n
t||�dSr))rrmrk)r#�otherrrr�
_set_statezsz!_chain_future.<locals>._set_statecs2|��r.�dus��ur"���n���j�dSr))rAr;�call_soon_threadsafe)�destination)�	dest_looprj�source_looprr�_call_check_cancel�s
z)_chain_future.<locals>._call_check_cancelcsJ���r�dur���rdS�dus,��ur8��|�n����|�dSr))rAZ	is_closedrp)rj)rorrrqrsrr�_call_set_state�s��z&_chain_future.<locals>._call_set_state)rrSrerfrrVrcrJ)rjrqrtrur)rorrrqrjrsr�
_chain_futurejs��	
rvrcCs2t|�r|S|durt��}|��}t||�|Sr))rrr
Z
create_futurerv)r#rZ
new_futurerrrr�s
r)�__all__Zconcurrent.futuresrerGZloggingr�typesr�rrr	r
rr7r8rC�DEBUGZSTACK_DEBUGrZ	_PyFuturercrdrirkrmrvrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s<
	*


?>