ok

Mini Shell

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



���]�g�
@s=dddddddddd	d
ddg
Zd
dlZd
dlZd
dlZd
dlZd
dlZd
dlZd
dlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddlmZGdd�de
j�Zej
jZej
jZej
jZedddddedd��Zdd�Zedddd��Zedd��Zdddddd�Zedddd d��Zddd!d"�Zee�d<de_[ddd#d�Zed$d%��ZGd&d'�d'e
j�Zddd(d)d*d	�Z ddd+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�)�compat)�
coroutines)�events)�futures)�	coroutinecs�eZdZej�ZiZdZeddd��Z	eddd��Z
dd�fdd	�Zej
r{d
d�Z�fdd
�Zdddd�Zdddddd�Zdd�Zd�fdd�Zdd�Z�S)rTNcCs(|dkrtj�}|jj|�S)N)r�get_event_loop�_current_tasks�get)�cls�loop�r�*/opt/alt/python35/lib64/python3.5/tasks.py�current_task/szTask.current_taskcs2�dkrtj���fdd�|jD�S)Ncs%h|]}|j�kr|�qSr)�_loop)�.0�t)rrr�	<setcomp>Cs	z!Task.all_tasks.<locals>.<setcomp>)rr�
_all_tasks)rrr)rr�	all_tasks;szTask.all_tasksrcskt�jd|�|jr&|jd=||_d|_d|_|jj|j�|j	j
j|�dS)NrrF���)�super�__init__�_source_traceback�_coro�_fut_waiter�_must_cancelr�	call_soon�_step�	__class__r!�add)�self�coror)r,rrr%Es	
			z
Task.__init__cCsg|jtjkrS|jrSd|ddi}|jrC|j|d<|jj|�tjj|�dS)N�task�messagez%Task was destroyed but it is pending!Zsource_traceback)	�_staterZ_PENDING�_log_destroy_pendingr&rZcall_exception_handler�Future�__del__)r.�contextrrrr5Ts	
zTask.__del__csrt�j�}|jr"d|d<tj|j�}|jdd|�|jdk	rn|jdd|j�|S)NZ
cancellingrrz	coro=<%s>�zwait_for=%r)r$�
_repr_infor)rZ_format_coroutiner'�insertr()r.�infor/)r,rrr8_s	
zTask._repr_info�limitcCs
g}y|jj}Wntk
r6|jj}YnX|dk	r�xI|dk	r�|dk	ru|dkrkP|d8}|j|�|j}qFW|j�nj|jdk	r|jj}xL|dk	r|dk	r�|dkr�P|d8}|j|j	�|j
}q�W|S)Nrr)r'�cr_frame�AttributeError�gi_frame�append�f_back�reverse�
_exception�
__traceback__�tb_frame�tb_next)r.r;Zframes�f�tbrrr�	get_stackms0






zTask.get_stack�filecCs]g}t�}x�|jd|�D]�}|j}|j}|j}|j}	||krr|j|�tj|�tj	|||j
�}
|j|||	|
f�q"W|j}|s�t
d|d|�n7|dk	r�t
d|d|�nt
d|d|�tj|d|�|dk	rYx3tj|j|�D]}
t
|
d|dd�q9WdS)Nr;zNo stack for %rrIz)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):�end�)�setrH�f_lineno�f_code�co_filename�co_namer-�	linecache�
checkcache�getline�	f_globalsr?rB�print�	traceback�
print_list�format_exception_onlyr,)r.r;rI�extracted_listZcheckedrF�lineno�co�filename�name�line�excrrr�print_stack�s0						

	


zTask.print_stackcCsHd|_|j�rdS|jdk	r;|jj�r;dSd|_dS)NFT)Z_log_traceback�doner(�cancelr))r.rrrrb�s		zTask.cancelcs|jr0t|tj�s'tj�}d|_|j}d|_||jj|j<z�y1|dkry|j	d�}n|j
|�}Wn�tk
r�}z=|jr�d|_|jtj��n|j
|j�WYdd}~Xntjk
r	t�j�Yn�tk
r:}z|j|�WYdd}~Xn�tk
rn}z|j|��WYdd}~Xn�Xt|dd�}|dk	ru|j|jk	r�|jj|jtdj||���q�|rJ||kr|jj|jtdj|���qrd|_|j|j�||_|jrr|jj�rrd|_q�|jj|jtdj||���n�|dkr�|jj|j�n_tj|�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}zGyield was used instead of yield from for generator in task {!r} with {}zTask got bad yield: {!r})r)�
isinstancer�CancelledErrorr'r(r,rr�send�throw�
StopIteration�
set_exception�
set_result�valuer$rb�	Exception�
BaseException�getattrr*r+�RuntimeError�formatrc�add_done_callback�_wakeup�inspectZisgenerator�pop)r.r_r/�result�blocking)r,rrr+�s~						"
								z
Task._stepcCsWy|j�Wn2tk
rB}z|j|�WYdd}~XnX|j�d}dS)N)rurlr+)r.�futurer_rrrrr4s 
zTask._wakeup)�__name__�
__module__�__qualname__�weakref�WeakSetr!rr3�classmethodrr"r%rZPY34r5r8rHr`rbr+rrrr)r,rrs 
		/#!Tr�timeout�return_whenc#s�tj|�stj|�r7tdt|�j��|sItd��|tt	t
fkrstdj|����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: {}cs"h|]}t|d���qS)r)r)rrF)rrrr gs	zwait.<locals>.<setcomp>)r�isfuturer�iscoroutine�	TypeError�typerx�
ValueErrorrrrrprrrL�_wait)�fsrr~rr)rrrLscGs|j�s|jd�dS)N)rarj)�waiter�argsrrr�_release_waiterlsr�ccs
|dkrtj�}|dkr-|EdHS|j�}|j|t|�}tjt|�}t|d|�}|j|�z|y
|EdHWn/t	j
k
r�|j|�|j��YnX|j
�r�|j�S|j|�|j�t	j��Wd|j�XdS)Nr)rr�
create_future�
call_laterr��	functools�partialrrqrre�remove_done_callbackrbraru�TimeoutError)�futr~rr��timeout_handle�cbrrrrqs,	






c#s|j��d�|dk	r3|j|t���t|������fdd�}x|D]}|j|�qaWz
�EdHWd�dk	r��j�Xt�t�}}xD|D]<}|j|�|j�r�|j	|�q�|j	|�q�W||fS)Ncs��d8��dksM�tksM�tkr||j�r||j�dk	r|�dk	rc�j��j�s|�jd�dS)Nrr)rr�	cancelled�	exceptionrbrarj)rF)�counterrr�r�rr�_on_completion�s

z_wait.<locals>._on_completion)
r�r�r��lenrqrbrLr�rar-)r�r~rrr�rFra�pendingr)r�rr�r�rr��s&



r�c#sLtj|�stj|�r7tdt|�j���dk	rI�n	tj���fdd�t	|�D��ddl
m}|d���d����fdd�}���fd	d
��t�fdd��}x�D]}|j
��q�W�r#|dk	r#�j||��x"tt���D]}|�Vq6WdS)
Nz expect a list of futures, not %scs"h|]}t|d���qS)r)r)rrF)rrrr �s	zas_completed.<locals>.<setcomp>r)�Queuercs9x(�D] }|j���jd�qW�j�dS)N)r��
put_nowait�clear)rF)r�ra�todorr�_on_timeout�s

z!as_completed.<locals>._on_timeoutcsE�s
dS�j|��j|��rA�dk	rA�j�dS)N)�remover�rb)rF)rar�r�rrr��s

z$as_completed.<locals>._on_completionc3s0�j�EdH}|dkr&tj�|j�S)N)rrr�ru)rF)rarr�
_wait_for_one�s	z#as_completed.<locals>._wait_for_one)rr�rr�r�r�rxrrrL�queuesr�rrqr��ranger�)r�rr~r�r�r�rF�_r)r�rarr�r�rr�s 
c
csv|dkrdV|S|dkr-tj�}|j�}|jj|tj||�}z
|EdHSWd|j�XdS)Nr)rrr�rr�rZ_set_result_unless_cancelledrb)�delayrurrw�hrrrrs
cCs&tjdtdd�t|d|�S)Nz;asyncio.async() function is deprecated, use ensure_future()�
stacklevelr7r)�warnings�warn�DeprecationWarningr)�coro_or_futurerrrr�async_s	r�cCs�tj|�r:|dk	r6||jk	r6td��|Stj|�r�|dkratj�}|j|�}|j	r�|j	d=|St
jr�tj
|�r�tt|�d|�Std��dS)Nz$loop argument must agree with Futurerrz:An asyncio.Future, a coroutine or an awaitable is requiredr#)rr�rr�rr�rrZcreate_taskr&rZPY35rsZisawaitabler�_wrap_awaitabler�)r�rr0rrrr+s	
ccs|j�EdHS)N)�	__await__)Z	awaitablerrrr�Bsr�cs4eZdZdd�fdd�Zdd�Z�S)�_GatheringFuturerNcs t�jd|�||_dS)Nr)r$r%�	_children)r.�childrenr)r,rrr%Tsz_GatheringFuture.__init__cCs@|j�rdSd}x#|jD]}|j�r d}q W|S)NFT)rar�rb)r.�retZchildrrrrbXs
z_GatheringFuture.cancel)rxryrzr%rbrr)r,rr�Lsr��return_exceptionsFcs|s;|dkrtj�}|j���jg��Si�x�t|�D]�}tj|�s�t|d|�}|dkr�|j}d|_	n9|}|dkr�|j}n|j|k	r�t
d��|�|<qNW�fdd�|D�}t|��t|d|��d�dg�������fdd�}x3t
|�D]%\}}|jtj||��qRW�S)	NrFz)futures are tied to different event loopscsg|]}�|�qSrr)r�arg)�
arg_to_futrr�
<listcomp>�s	zgather.<locals>.<listcomp>rcs��j�r&|j�s"|j�dS|j�rXtj�}�s��j|�dSn>|jdk	r�|j�}�s��j|�dSn	|j}|�|<�d7���kr��j��dS)Nr)	rar�r�rrerirB�_resultrj)�ir��res)�	nchildren�	nfinished�outer�resultsr�rr�_done_callback�s&


	

zgather.<locals>._done_callback)rrr�rjrLrr�rrr3r�r�r��	enumeraterqr�r�)rr�Zcoros_or_futuresr�r�r�r�r�r)r�r�r�r�r�r�rr
bs8
	
csZt|d|�}|j�r"|S|j}|j���fdd�}|j|��S)Nrcs~�j�r&|j�s"|j�dS|j�r?�j�n;|j�}|dk	rg�j|�n�j|j��dS)N)r�r�rbrirjru)�innerr_)r�rrr��s

zshield.<locals>._done_callback)rrarr�rq)r�rr�r�r)r�rr�s	
csStj��std��tjj�����fdd�}�j|��S)NzA coroutine object is requiredcshy tjt�d����WnAtk
rc}z!�j�rN�j|��WYdd}~XnXdS)Nr)rZ
_chain_futurerrl�set_running_or_notify_cancelri)r_)r/rwrrr�callback�s 
z*run_coroutine_threadsafe.<locals>.callback)rr�r��
concurrentrr4Zcall_soon_threadsafe)r/rr�r)r/rwrrr
�s
)#�__all__�concurrent.futuresr�r�rsrQrVr�r{rKrrrrrr4rrrrrr�rr�rrr��globalsrxrr�r�r
rr
rrrr�<module>sN	�0--8
	
T5

Zerion Mini Shell 1.0