AlkantarClanX12

Your IP : 3.12.34.150


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

3


 \�a�
@s�dddddddddd	d
ddg
Zd
dlZd
dlZd
dlZd
dlZd
dlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZddl
m
Z
Gdd�dej�ZeZyd
dlZWnek
r�YnXejZZejjZejjZejjZe
dded�dd��Zdd�Ze
dd�dd��Ze
dd��Zddd�d d�Ze
d.dd�d!d��Zdd�d"d#�Zee�d<de_[dd�d$d�Z e
d%d&��Z!Gd'd(�d(ej�Z"dd)d*�d+d	�Z#dd�d,d
�Z$d-d�Z%dS)/�Task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�async�gather�shield�
ensure_future�run_coroutine_threadsafe�N�)�
base_tasks)�compat)�
coroutines)�events)�futures)�	coroutinecs�eZdZej�ZiZdZeddd��Z	eddd��Z
dd��fdd	�
Zej
rTd
d�Zdd
�Zdd�dd�Zddd�dd�Zdd�Zd�fdd�	Zdd�Z�ZS)rTNcCs|dkrtj�}|jj|�S)N)r�get_event_loop�_current_tasks�get)�cls�loop�r�%/usr/lib64/python3.6/asyncio/tasks.py�current_task.szTask.current_taskcs$�dkrtj���fdd�|jD�S)Ncsh|]}|j�kr|�qSr)�_loop)�.0�t)rrr�	<setcomp>Bsz!Task.all_tasks.<locals>.<setcomp>)rr�
_all_tasks)rrr)rr�	all_tasks:szTask.all_tasks)rcsNt�j|d�|jr|jd=||_d|_d|_|jj|j�|j	j
j|�dS)N)rrF���)�super�__init__�_source_traceback�_coro�_fut_waiter�_must_cancelr�	call_soon�_step�	__class__r"�add)�self�coror)r-rrr&Dsz
Task.__init__cCsH|jtjkr8|jr8|dd�}|jr,|j|d<|jj|�tjj|�dS)Nz%Task was destroyed but it is pending!)�task�messageZsource_traceback)	Z_staterZ_PENDING�_log_destroy_pendingr'rZcall_exception_handler�Future�__del__)r/�contextrrrr5Ss
zTask.__del__cCs
tj|�S)N)rZ_task_repr_info)r/rrr�
_repr_info^szTask._repr_info)�limitcCstj||�S)N)rZ_task_get_stack)r/r8rrr�	get_stackaszTask.get_stack)r8�filecCstj|||�S)N)rZ_task_print_stack)r/r8r:rrr�print_stackxs	zTask.print_stackcCs4d|_|j�rdS|jdk	r*|jj�r*dSd|_dS)NFT)Z_log_traceback�doner)�cancelr*)r/rrrr=�s

zTask.cancelcsf|jr t|tj�stj�}d|_|j}d|_||jj|j<�zy"|dkrT|j	d�}n
|j
|�}Wn�tk
r�}z.|jr�d|_|jtj��n|j
|j�WYdd}~X�n�tjk
r�t�j�Y�n|tk
r�}z|j|�WYdd}~X�nPtk
�r(}z|j|��WYdd}~X�n Xt|dd�}|dk	�r�|j|jk	�rl|jj|jtdj||���n||�r�||k�r�|jj|jtdj|���n2d|_|j|j�||_|j�r�|jj��r�d|_n|jj|jtdj||���n^|dk�r|jj|j�nDtj|��r.|jj|jtdj||���n|jj|jtdj|���Wd|jjj|j�d}XdS)NF�_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r*�
isinstancer�CancelledErrorr(r)r-rr�send�throw�
StopIteration�
set_exception�
set_result�valuer%r=�	Exception�
BaseException�getattrr+r,�RuntimeError�formatr>�add_done_callback�_wakeup�inspectZisgenerator�pop)r/�excr0�resultZblocking)r-rrr,�s~



z
Task._stepcCsJy|j�Wn,tk
r8}z|j|�WYdd}~Xn
X|j�d}dS)N)rQrGr,)r/�futurerPrrrrM�szTask._wakeup)N)N)N)�__name__�
__module__�__qualname__�weakref�WeakSetr"rr3�classmethodrr#r&rZPY34r5r7r9r;r=r,rM�
__classcell__rr)r-rrs 
	!T)r�timeout�return_whenc#s�tj|�stj|�r&tdt|�j��|s2td��|tt	t
fkrNtdj|����dkr^tj
���fdd�t|�D�}t|||��EdHS)Nz expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}csh|]}t|�d��qS))r)r)r�f)rrrr!7szwait.<locals>.<setcomp>)r�isfuturer�iscoroutine�	TypeError�typerS�
ValueErrorrrrrKrr�set�_wait)�fsrrZr[r)rrrscGs|j�s|jd�dS)N)r<rE)�waiter�argsrrr�_release_waiter<srg)rccs�|dkrtj�}|dkr"|EdHS|j�}|j|t|�}tjt|�}t||d�}|j|�zhy|EdHWn*t	j
k
r�|j|�|j��YnX|j
�r�|j�S|j|�|j�t	j��Wd|j�XdS)N)r)rr�
create_future�
call_laterrg�	functools�partialrrLrr@�remove_done_callbackr=r<rQ�TimeoutError)�futrZrre�timeout_handle�cbrrrrAs,



c#s�|j��d�|dk	r"|j|t���t|������fdd�}x|D]}|j|�qBWz�EdHWd�dk	rt�j�Xt�t�}}x4|D],}|j|�|j�r�|j	|�q�|j	|�q�W||fS)Ncs\�d8��dks6�tks6�tkrX|j�rX|j�dk	rX�dk	rF�j��j�sX�jd�dS)Nrr)rr�	cancelled�	exceptionr=r<rE)r\)�counterr[rorerr�_on_completion|sz_wait.<locals>._on_completion)
rhrirg�lenrLr=rbrlr<r.)rdrZr[rrtr\r<�pendingr)rsr[rorerrcos&



rc)rrZc#s�tj|�stj|�r&tdt|�j���dk	r2�ntj���fdd�t	|�D��ddl
m}|�d��d����fdd�}���fd	d
��t�fdd��}x�D]}|j
��q�W�r�|dk	rʈj||��xtt���D]}|�Vq�WdS)
Nz expect a list of futures, not %scsh|]}t|�d��qS))r)r)rr\)rrrr!�szas_completed.<locals>.<setcomp>r)�Queue)rcs.x �D]}|j���jd�qW�j�dS)N)rl�
put_nowait�clear)r\)rtr<�todorr�_on_timeout�s

z!as_completed.<locals>._on_timeoutcs6�sdS�j|��j|��r2�dk	r2�j�dS)N)�removerxr=)r\)r<rorzrrrt�s

z$as_completed.<locals>._on_completionc3s$�j�EdH}|dkrtj�|j�S)N)rrrmrQ)r\)r<rr�
_wait_for_one�sz#as_completed.<locals>._wait_for_one)rr]rr^r_r`rSrrrbZqueuesrwrrLri�rangeru)rdrrZrwr{r}r\�_r)rtr<rrorzrr�s 

c
csX|dkrdV|S|dkr"tj�}|j�}|jj|tj||�}z
|EdHS|j�XdS)Nr)rrrhrrirZ_set_result_unless_cancelledr=)ZdelayrQrrR�hrrrr�s
cCstjdtdd�t||d�S)Nz;asyncio.async() function is deprecated, use ensure_future()�)�
stacklevel)r)�warnings�warn�DeprecationWarningr)�coro_or_futurerrrr�async_�sr�cCs�tj|�r(|dk	r$||jk	r$td��|Stj|�r^|dkrBtj�}|j|�}|j	rZ|j	d=|St
jr~tj
|�r~tt|�|d�Std��dS)Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr]rrarr^rrZcreate_taskr'rZPY35rNZisawaitabler�_wrap_awaitabler_)r�rr1rrrr�s


ccs|j�EdHS)N)�	__await__)Z	awaitablerrrr�sr�cs*eZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFutureN)rcst�j|d�||_d|_dS)N)rF)r%r&�	_children�_cancel_requested)r/�childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|j�rdSd}x|jD]}|j�rd}qW|r6d|_|S)NFT)r<r�r=r�)r/ZretZchildrrrr=)sz_GatheringFuture.cancel)rSrTrUr&r=rYrr)r-rr�sr�F)r�return_exceptionscs|s*|dkrtj�}|j���jg��Si�xjt|�D]^}tj|�sht||d�}|dkr`|j}d|_	n&|}|dkr||j}n|j|k	r�t
d��|�|<q8W�fdd�|D�}t|��t||d��d�dg�������fdd�}x&t
|�D]\}}|jtj||��q�W�S)	N)rFz)futures are tied to different event loopscsg|]}�|�qSrr)r�arg)�
arg_to_futrr�
<listcomp>hszgather.<locals>.<listcomp>rcs��j�r|j�s|j�dS|j�r@tj�}�sl�j|�dSn,|jdk	rf|j�}�sl�j|�dSn|j}|�|<�d7���kr��jr��jtj��n
�j	��dS)Nr)
r<rqrrrr@rDZ
_exceptionZ_resultr�rE)�irn�res)�	nchildren�	nfinished�outer�resultsr�rr�_done_callbackns*


zgather.<locals>._done_callback)rrrhrErbrr]rrr3rarur��	enumeraterLrjrk)rr�Zcoros_or_futuresr�rnr�r�r�r)r�r�r�r�r�r�rr
8s8



cs@t||d�}|j�r|S|j}|j���fdd�}|j|��S)N)rcs\�j�r|j�s|j�dS|j�r.�j�n*|j�}|dk	rJ�j|�n�j|j��dS)N)rqrrr=rDrErQ)�innerrP)r�rrr��s
zshield.<locals>._done_callback)rr<rrhrL)r�rr�r�r)r�rr�s
cs:tj��std��tjj�����fdd�}�j|��S)NzA coroutine object is requiredcsTytjt��d���Wn6tk
rN}z�j�r<�j|��WYdd}~XnXdS)N)r)rZ
_chain_futurerrGZset_running_or_notify_cancelrD)rP)r0rRrrr�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rr^r_�
concurrentrr4Zcall_soon_threadsafe)r0rr�r)r0rRrrr
�s


)N)&�__all__Zconcurrent.futuresr�rjrNr�rV�rrrrrrr4rZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrgrrcrrr��globalsrSrr�r�r
rr
rrrr�<module>sX
s
--8

W5