Your IP : 3.145.88.155


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

U

i�fb3�@s�dZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ejZejZej
Z
ejZejdZGdd	�d	�ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�dd�ZzddlZWnek
r�YnXejZZdS))�Future�wrap_future�isfuture�N�)�base_futures)�events)�
exceptions)�format_helpersc@s�eZdZeZdZdZdZdZdZ	dZ
dd�dd�Zej
Zdd�Zdd	�Zed
d��Zejdd��Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�dd�Zdd�Zd d!�Zd"d#�Zd$d%�ZeZ dS)&rNF��loopcCs@|dkrt��|_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/python38/lib64/python3.8/asyncio/futures.py�__init__Ds
�zFuture.__init__cCsd�|jjd�|����S)Nz<{} {}>� )�format�	__class__�__name__�join�
_repr_info�rrrr�__repr__Vs
�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�
_exceptionrrrr
Zcall_exception_handler)r�exc�contextrrr�__del__Zs�
zFuture.__del__cCs|jS�N)r#rrrr�_log_tracebackjszFuture._log_tracebackcCst|�rtd��d|_dS)Nz'_log_traceback can only be set to FalseF)�bool�
ValueErrorr#)r�valrrrr)nscCs|j}|dkrtd��|S)Nz!Future object is not initialized.)r
�RuntimeErrorrrrr�get_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|��dS)NFT)r#�_state�_PENDING�
_CANCELLED�_Future__schedule_callbacksrrrr�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()r/r1rrrr�	cancelled�szFuture.cancelledcCs
|jtkSr()r/r0rrrr�done�szFuture.donecCs@|jtkrtj�|jtkr$t�d��d|_|jdk	r:|j�|jS)NzResult is not ready.F)	r/r1r�CancelledError�	_FINISHED�InvalidStateErrorr#r$�_resultrrrr�result�s



z
Future.resultcCs0|jtkrtj�|jtkr$t�d��d|_|jS)NzException is not set.F)r/r1rr;r<r=r#r$rrrrr!�s


zFuture.exceptionr5cCsB|jtkr|jj|||d�n |dkr.t��}|j�||f�dSr4)r/r0r
r6�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�fr8�rBrr�
<listcomp>�s�z/Future.remove_done_callback.<locals>.<listcomp>)r�len)rrBZfiltered_callbacksZ
removed_countrrFr�remove_done_callback�s
�zFuture.remove_done_callbackcCs8|jtkr t�|j�d|����||_t|_|��dS)N�: )r/r0rr=r>r<r2)rr?rrr�
set_result�s

zFuture.set_resultcCsb|jtkr t�|j�d|����t|t�r0|�}t|�tkrDtd��||_t	|_|�
�d|_dS)NrJzPStopIteration interacts badly with generators and cannot be raised into a FutureT)r/r0rr=�
isinstance�type�
StopIteration�	TypeErrorr$r<r2r#)rr!rrr�
set_exception�s

zFuture.set_exceptionccs,|��sd|_|V|��s$td��|��S)NTzawait wasn't used with future)r:�_asyncio_future_blockingr-r?rrrr�	__await__szFuture.__await__)!r�
__module__�__qualname__r0r/r>r$r
rrQr#rrZ_future_repr_inforrr'�propertyr)�setterr.r3r2r9r:r?r!rCrIrKrPrR�__iter__rrrrrs8

rcCs,z
|j}Wntk
rYnX|�S|jSr()r.�AttributeErrorr
)�futr.rrr�	_get_loops
rZcCs|��rdS|�|�dSr()r9rK)rYr?rrr�_set_result_unless_cancelledsr[cCsXt|�}|tjjkr tj|j�S|tjjkr8tj|j�S|tjjkrPtj|j�S|SdSr()rM�
concurrent�futuresr;r�args�TimeoutErrorr=)r%Z	exc_classrrr�_convert_future_exc#sr`cCsR|��r|��|��sdS|��}|dk	r<|�t|��n|��}|�|�dSr()r9r3Zset_running_or_notify_cancelr!rPr`r?rK)r\�sourcer!r?rrr�_set_concurrent_future_state/srbcCsT|��rdS|��r|��n2|��}|dk	r>|�t|��n|��}|�|�dSr()r9r3r!rPr`r?rK)ra�destr!r?rrr�_copy_future_state>s
rdcs�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()rrdrb)r"�otherrrr�
_set_statebsz!_chain_future.<locals>._set_statecs2|��r.�dks��kr"���n���j�dSr()r9r3�call_soon_threadsafe)�destination)�	dest_loopra�source_looprr�_call_check_cancelhs
z)_chain_future.<locals>._call_check_cancelcsJ���r�dk	r���rdS�dks,��kr8��|�n����|�dSr()r9Z	is_closedrg)ra)rfrirhrjrr�_call_set_stateos��z&_chain_future.<locals>._call_set_state)rrLr\r]rrOrZrC)rarhrkrlr)rfrirhrarjr�
_chain_futureRs��	
rmr
cCs2t|�r|S|dkrt��}|��}t||�|Sr()rrrZ
create_futurerm)r"rZ
new_futurerrrr|s
r)�__all__Zconcurrent.futuresr\r@Zloggingr�rrrr	rr0r1r<�DEBUGZSTACK_DEBUGrZ	_PyFuturerZr[r`rbrdrmrZ_asyncio�ImportErrorZ_CFuturerrrr�<module>s8
q*


?>