Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/asyncio/__pycache__/tasks.cpython-37.opt-2.pyc

B

YI~d�w�@s<dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddlmZd=d	d
�Zd>dd�Zd?d
d�ZGdd�de
j�ZeZyddlZWnek
r�YnXejZZdd�Zej
jZej
jZej
jZdded�dd�Zdd�Zdd�dd�Zdd�Zdd�Z ddd�d d!�Z!ejd"d#��Z"d@dd�d$d%�Z#dd�d&d'�Z$ed(d)��Z%Gd*d+�d+e
j&�Z'dd,d-�d.d/�Z(dd�d0d1�Z)d2d3�Z*e�+�Z,iZ-d4d5�Z.d6d7�Z/d8d9�Z0d:d;�Z1e.Z2e1Z3e/Z4e0Z5y$dd<lm.Z.m1Z1m/Z/m0Z0m,Z,m-Z-Wnek
�r&YnXe.Z6e1Z7e/Z8e0Z9dS)A)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield�
ensure_future�run_coroutine_threadsafe�current_task�	all_tasks�_register_task�_unregister_task�_enter_task�_leave_task�N�)�
base_tasks)�
coroutines)�events)�futures)�	coroutinecCs|dkrt��}t�|�S)N)r�get_running_loop�_current_tasks�get)�loop�r�2/opt/alt/python37/lib64/python3.7/asyncio/tasks.pyrsrcsb�dkrt���d}x:ytt�}Wn&tk
rH|d7}|dkrD�YqXPqW�fdd�|D�S)Nrri�cs&h|]}t�|��kr|��s|�qSr)r�	_get_loop�done)�.0�t)rrr �	<setcomp>5szall_tasks.<locals>.<setcomp>)rr�list�
_all_tasks�RuntimeError)r�i�tasksr)rr r"srcsb�dkrt���d}x:ytt�}Wn&tk
rH|d7}|dkrD�YqXPqW�fdd�|D�S)Nrri�csh|]}t�|��kr|�qSr)rr!)r#r$)rrr r%Nsz$_all_tasks_compat.<locals>.<setcomp>)r�get_event_loopr&r'r()rr)r*r)rr �_all_tasks_compat9sr,cs�eZdZdZeddd��Zeddd��Zdd��fdd	�
Z�fd
d�Zdd
�Z	dd�Z
dd�Zdd�dd�Zddd�dd�Z
dd�Zd �fdd�	Zdd�Z�ZS)!rTNcCs(tjdtdd�|dkr t��}t|�S)NzETask.current_task() is deprecated, use asyncio.current_task() instead�)�
stacklevel)�warnings�warn�PendingDeprecationWarningrr+r)�clsrrrr rcszTask.current_taskcCstjdtdd�t|�S)Nz?Task.all_tasks() is deprecated, use asyncio.all_tasks() insteadr-)r.)r/r0r1r,)r2rrrr rsszTask.all_tasks)rcsvt�j|d�|jr|jd=t�|�s:d|_td|����d|_d|_||_	t
��|_|j
j|j|jd�t|�dS)N)r���Fza coroutine was expected, got )�context)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending�	TypeError�_must_cancel�_fut_waiter�_coro�contextvarsZcopy_context�_context�_loop�	call_soon�_Task__stepr)�self�coror)�	__class__rr r6s

z
Task.__init__csF|jtjkr8|jr8|dd�}|jr,|j|d<|j�|�t���dS)Nz%Task was destroyed but it is pending!)�task�messageZsource_traceback)	Z_staterZ_PENDINGr9r7r@Zcall_exception_handlerr5�__del__)rCr4)rErr rH�s
zTask.__del__cCs
t�|�S)N)rZ_task_repr_info)rCrrr �
_repr_info�szTask._repr_infocCstd��dS)Nz*Task does not support set_result operation)r()rC�resultrrr �
set_result�szTask.set_resultcCstd��dS)Nz-Task does not support set_exception operation)r()rC�	exceptionrrr �
set_exception�szTask.set_exception)�limitcCst�||�S)N)rZ_task_get_stack)rCrNrrr �	get_stack�szTask.get_stack)rN�filecCst�|||�S)N)rZ_task_print_stack)rCrNrPrrr �print_stack�s	zTask.print_stackcCs4d|_|��rdS|jdk	r*|j��r*dSd|_dS)NFT)Z_log_tracebackr"r<�cancelr;)rCrrr rR�s

zTask.cancelc
s�|��rt�d|�d|����|jr>t|tj�s8t��}d|_|j}d|_t|j	|��zhy"|dkrp|�
d�}n
|�|�}Wn�tk
r�}z0|jr�d|_t
��t���nt
��|j�Wdd}~XY�n�tjk
r�t
���Y�n�tk
�r}zt
��|�Wdd}~XY�n�tk
�rN}zt
��|��Wdd}~XY�npXt|dd�}|dk	�rBt�|�|j	k	�r�td|�d|�d��}|j	j|j||jd�n�|�r||k�r�td	|���}|j	j|j||jd�n8d|_|j|j|jd�||_|j�r@|j���r@d|_n*td
|�d|���}|j	j|j||jd�n||dk�rb|j	j|j|jd�n\t�|��r�td|�d|���}|j	j|j||jd�n$td
|���}|j	j|j||jd�Wdt|j	|�d}XdS)Nz_step(): already done: z, F�_asyncio_future_blockingzTask z got Future z attached to a different loop)r4zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: ) r"rZInvalidStateErrorr;�
isinstance�CancelledErrorr=r<rr@�send�throw�
StopIterationr5rMrK�valuerR�	Exception�
BaseException�getattrr!r(rArBr?rS�add_done_callback�
_Task__wakeup�inspectZisgeneratorr)rC�excrDrJZblocking�new_exc)rErr Z__step�s| 


zTask.__stepc
CsJy|��Wn,tk
r8}z|�|�Wdd}~XYn
X|��d}dS)N)rJrZrB)rC�futurer`rrr Z__wakeup<sz
Task.__wakeup)N)N)N)�__name__�
__module__�__qualname__r9�classmethodrrr6rHrIrKrMrOrQrRrBr^�
__classcell__rr)rEr rQs!TrcCst��}|�|�S)N)rrr)rDrrrr rYsr)r�timeout�return_whenc�s�t�|�st�|�r(tdt|�j����|s4td��|tt	t
fkrPtd|�����dkr`t����fdd�t
|�D�}t|||��IdHS)Nzexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: csh|]}t|�d��qS))r)r)r#�f)rrr r%�szwait.<locals>.<setcomp>)r�isfuturerr8r:�typerc�
ValueErrorrrrrr+�set�_wait)�fsrrhrir)rr risrcGs|��s|�d�dS)N)r"rK)�waiter�argsrrr �_release_waiter�srs)rc�s|dkrt��}|dkr"|IdHS|dkrVt||d�}|��rF|��S|��t���|��}|�	|t
|�}t�t
|�}t||d�}|�
|�zry|IdHWn*tjk
r�|�|�|���YnX|��r�|��S|�|�t||d�IdHt���Wd|��XdS)Nr)r)rr+rr"rJrRr�TimeoutError�
create_future�
call_laterrs�	functools�partialr]rU�remove_done_callback�_cancel_and_wait)�futrhrrq�timeout_handle�cbrrr r�s8




rc
�s�|���d�|dk	r"|�|t���t|������fdd�}x|D]}|�|�qBWz�IdHWd�dk	rt���x|D]}|�|�qzWXt�t�}}x*|D]"}|��r�|�	|�q�|�	|�q�W||fS)NcsZ�d8��dks4�tks4�tkrV|��sV|��dk	rV�dk	rD������sV��d�dS)Nrr)rr�	cancelledrLrRr"rK)rj)�counterrir|rqrr �_on_completion�sz_wait.<locals>._on_completion)
rurvrs�lenr]rRryrnr"�add)rprhrirr�rjr"Zpendingr)rrir|rqr ro�s(


roc	�sF|��}t�t|�}|�|�z|��|IdHWd|�|�XdS)N)rurwrxrsr]rRry)r{rrqr}rrr rz�s
rz)rrhc#s�t�|�st�|�r(tdt|�j�����dk	r4�nt����fdd�t	|�D��ddl
m}|�d��d����fdd�}���fd	d
���fdd�}x�D]}|���q�W�r�|dk	rȈ�
||��xtt���D]}|�Vq�WdS)
Nzexpect a list of futures, not csh|]}t|�d��qS))r)r)r#rj)rrr r%szas_completed.<locals>.<setcomp>r)�Queue)rcs.x �D]}|�����d�qW���dS)N)ry�
put_nowait�clear)rj)r�r"�todorr �_on_timeouts

z!as_completed.<locals>._on_timeoutcs4�sdS��|���|��s0�dk	r0���dS)N)�remover�rR)rj)r"r|r�rr r�#s

z$as_completed.<locals>._on_completionc�s$���IdH}|dkrtj�|��S)N)rrrtrJ)rj)r"rr �
_wait_for_one+sz#as_completed.<locals>._wait_for_one)rrkrr8r:rlrcrr+rnZqueuesr�r]rv�ranger�)rprrhr�r�r�rj�_r)r�r"rr|r�r rs 

rccs
dVdS)Nrrrrr �__sleep0:s	r�c�s\|dkrt�IdH|S|dkr(t��}|��}|�|tj||�}z
|IdHS|��XdS)Nr)r�rr+rurvrZ_set_result_unless_cancelledrR)ZdelayrJrrb�hrrr r	Fs
r	cCs�t�|�r6|dkrt��}|�|�}|jr2|jd=|St�|�rb|dk	r^|t�|�k	r^t	d��|St
�|�r|tt
|�|d�Std��dS)Nr3z$loop argument must agree with Future)rz:An asyncio.Future, a coroutine or an awaitable is required)rr8rr+rr7rrkr!rmr_Zisawaitabler�_wrap_awaitabler:)Zcoro_or_futurerrFrrr rXs



rccs|��EdHS)N)�	__await__)Z	awaitablerrr r�osr�cs*eZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFutureN)rcst�j|d�||_d|_dS)N)rF)r5r6�	_children�_cancel_requested)rC�childrenr)rErr r6�sz_GatheringFuture.__init__cCs:|��rdSd}x|jD]}|��rd}qW|r6d|_|S)NFT)r"r�rRr�)rC�retZchildrrr rR�sz_GatheringFuture.cancel)rcrdrer6rRrgrr)rEr r�ysr�F)r�return_exceptionscs�|s*|dkrt��}|�����g��S�����fdd�}i}g�d�d�xn|D]f}||kr�t||d�}|dkr~t�|�}||k	r�d|_�d7�|||<|�|�n||}��	|�qTWt
�|d���S)Ncs��d7����r$|��s |��dS�sd|��rFt��}��|�dS|��}|dk	rd��|�dS��kr�g}x@�D]8}|��r�t��}n|��}|dkr�|��}|�|�qvW�jrȈ�t���n
��	|�dS)Nr)
r"r~rLrrUrMrJ�appendr�rK)r{r`�resultsZres)r��	nfinished�nfuts�outerr�rr �_done_callback�s4



zgather.<locals>._done_callbackr)rFr)rr+rurKrrr!r9r]r�r�)rr�Zcoros_or_futuresr�Z
arg_to_fut�argr{r)r�r�r�r�r�r r
�s2
1

r
cs\t||d�����r�St���}|����fdd����fdd�}������|��S)N)rcs\���r|��s|��dS|��r.���n*|��}|dk	rJ��|�n��|���dS)N)r~rLrRrMrKrJ)�innerr`)r�rr �_inner_done_callback#s
z$shield.<locals>._inner_done_callbackcs���s����dS)N)r"ry)r�)r�r�rr �_outer_done_callback4sz$shield.<locals>._outer_done_callback)rr"rr!rur])r�rr�r)r�r�r�r rs


rcs:t���std��tj������fdd�}��|��S)NzA coroutine object is requiredc
sTyt�t��d���Wn6tk
rN}z���r<��|��Wdd}~XYnXdS)N)r)rZ
_chain_futurerrZZset_running_or_notify_cancelrM)r`)rDrbrrr �callbackFs
z*run_coroutine_threadsafe.<locals>.callback)rr8r:�
concurrentr�FutureZcall_soon_threadsafe)rDrr�r)rDrbrr r
=s


r
cCst�|�dS)N)r'r�)rFrrr rZsrcCs4t�|�}|dk	r(td|�d|�d���|t|<dS)NzCannot enter into task z while another task z is being executed.)rrr()rrFrrrr r_s
rcCs2t�|�}||k	r(td|�d|�d���t|=dS)Nz
Leaving task z! does not match the current task �.)rrr()rrFrrrr rgs
rcCst�|�dS)N)r'�discard)rFrrr rosr)rrrrr'r)N)N)N)N):�__all__�concurrent.futuresr�r>rwr_�typesr/�weakref�rrrrrrrr,Z	_PyFuturerZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrrsrrorzrr�r	rr�r�r�r
rr
ZWeakSetr'rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ
_c_enter_taskZ
_c_leave_taskrrrr �<module>sv


}
9,7
m;$

Hacked By AnonymousFox1.0, Coded By AnonymousFox