AlkantarClanX12

Your IP : 18.218.95.236


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

a

R�fs��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
l
mZe�d�jZdDdd�ZdEd
d�ZdFdd�Zdd�ZGdd�dej�ZeZzddlZWne�yYn0ejZZdd�dd�Zejj Z ejj!Z!ejj"Z"dde"d�dd�Z#dd�Z$dd�dd�Z%d d!�Z&d"d#�Z'ddd$�d%d&�Z(ej)d'd(��Z*dGdd�d)d*�Z+dd�d+d,�Z,ej)d-d.��Z-ee-_Gd/d0�d0ej.�Z/dd1d2�d3d4�Z0dd1d2�d5d6�Z1dd�d7d8�Z2d9d:�Z3e	�4�Z5iZ6d;d<�Z7d=d>�Z8d?d@�Z9dAdB�Z:e7Z;e:Z<e8Z=e9Z>z$ddClm7Z7m:Z:m8Z8m9Z9m5Z5m6Z6Wne�yvYn0e7Z?e:Z@e8ZAe9ZBdS)H)�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)�GenericAlias�)�
base_tasks)�
coroutines)�events)�
exceptions)�futures)�
_is_coroutinecCs|durt��}t�|�S�N)r�get_running_loop�_current_tasks�get��loop�r#�2/opt/alt/python39/lib64/python3.9/asyncio/tasks.pyr#srcs\�durt���d}ztt�}WqJtyD|d7}|dkr@�Yq0qJq�fdd�|D�S)Nrr��cs&h|]}t�|��ur|��s|�qSr#)r�	_get_loop�done��.0�tr!r#r$�	<setcomp>=s�zall_tasks.<locals>.<setcomp>)rr�list�
_all_tasks�RuntimeError�r"�iZtasksr#r!r$r*srcs\�durt���d}ztt�}WqJtyD|d7}|dkr@�Yq0qJq�fdd�|D�S)Nrrr%csh|]}t�|��ur|�qSr#)rr&r(r!r#r$r+V�z$_all_tasks_compat.<locals>.<setcomp>)r�get_event_loopr,r-r.r/r#r!r$�_all_tasks_compatAsr3cCs2|dur.z
|j}Wnty$Yn
0||�dSr)�set_name�AttributeError)�task�namer4r#r#r$�_set_task_nameYs
r8cs�eZdZdZddd��fdd�
Z�fdd�Zee�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�dd�Zddd�dd�Zd dd�Zd!�fdd�	Zdd�Z�ZS)"rTN)r"r7cs�t�j|d�|jr|jd=t�|�s:d|_td|����|durRdt���|_n
t	|�|_d|_
d|_||_t
��|_|jj|j|jd�t|�dS)Nr!���Fza coroutine was expected, got zTask-��context)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending�	TypeError�_task_name_counter�_name�str�_must_cancel�_fut_waiter�_coro�contextvarsZcopy_context�_context�_loop�	call_soon�_Task__stepr)�self�coror"r7��	__class__r#r$r=us


z
Task.__init__csF|jtjkr8|jr8|dd�}|jr,|j|d<|j�|�t���dS)Nz%Task was destroyed but it is pending!)r6�messageZsource_traceback)	Z_staterZ_PENDINGr@r>rJZcall_exception_handlerr<�__del__)rMr;rOr#r$rR�s�
zTask.__del__cCs
t�|�Sr)rZ_task_repr_info�rMr#r#r$�
_repr_info�szTask._repr_infocCs|jSr)rGrSr#r#r$�get_coro�sz
Task.get_corocCs|jSr)rCrSr#r#r$�get_name�sz
Task.get_namecCst|�|_dSr)rDrC)rM�valuer#r#r$r4�sz
Task.set_namecCstd��dS)Nz*Task does not support set_result operation�r.)rM�resultr#r#r$�
set_result�szTask.set_resultcCstd��dS)Nz-Task does not support set_exception operationrX)rM�	exceptionr#r#r$�
set_exception�szTask.set_exception)�limitcCst�||�Sr)rZ_task_get_stack)rMr]r#r#r$�	get_stack�szTask.get_stack)r]�filecCst�|||�Sr)rZ_task_print_stack)rMr]r_r#r#r$�print_stack�s	zTask.print_stackcCs>d|_|��rdS|jdur.|jj|d�r.dSd|_||_dS�NF��msgT)Z_log_tracebackr'rF�cancelrE�_cancel_message)rMrcr#r#r$rd�s
zTask.cancelc
s|��rt�d|�d|����|jr>t|tj�s8|��}d|_|j}d|_t	|j
|��z�z"|durp|�d�}n
|�|�}Wn�t
y�}z:|jr�d|_t�j|jd�nt��|j�WYd}~�n d}~0tj�y}z||_t���WYd}~�n�d}~0ttf�y>}zt��|��WYd}~�n�d}~0t�yp}zt��|�WYd}~�n~d}~00t|dd�}|du�rjt�|�|j
u�r�td|�d|�d��}|j
j|j||jd	�n�|�r>||u�r�td
|���}|j
j|j||jd	�n>d|_|j |j!|jd	�||_|j�rh|jj|jd��rhd|_n*td|�d|���}|j
j|j||jd	�n||du�r�|j
j|j|jd	�n\t"�#|��r�td
|�d|���}|j
j|j||jd	�n$td|���}|j
j|j||jd	�Wt$|j
|�d}nt$|j
|�d}0dS)Nz_step(): already done: z, Frb�_asyncio_future_blockingzTask z got Future z attached to a different loopr:zTask 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'rZInvalidStateErrorrE�
isinstance�CancelledError�_make_cancelled_errorrGrFrrJ�send�throw�
StopIterationr<rdrerZrWZ_cancelled_exc�KeyboardInterrupt�
SystemExitr\�
BaseException�getattrrr&r.rKrLrIrf�add_done_callback�
_Task__wakeup�inspectZisgeneratorr)rM�excrNrYZblocking�new_excrOr#r$Z__step�s��$ $
��
�
�
������
�
���
�
��zTask.__stepc
CsLz|��Wn.ty:}z|�|�WYd}~nd}~00|��d}dSr)rYrorL)rM�futurertr#r#r$Z__wakeupFs z
Task.__wakeup)N)N)�__name__�
__module__�__qualname__r@r=rR�classmethodr�__class_getitem__rTrUrVr4rZr\r^r`rdrLrr�
__classcell__r#r#rOr$rcs
"Wr)r7cCs t��}|�|�}t||�|Sr)rrrr8)rNr7r"r6r#r#r$rcs

r)r"�timeout�return_whenc�s�t�|�st�|�r(tdt|�j����|s4td��|tt	t
fvrPtd|�����durbt���nt
jdtdd�t|�}tdd�|D��r�t
jd	tdd��fd
d�|D�}t|||��IdHS)Nzexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: �[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.���
stacklevelcss|]}t�|�VqdSr)rr?�r)�fr#r#r$�	<genexpr>�r1zwait.<locals>.<genexpr>z�The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.csh|]}t|�d��qS�r!�rr�r!r#r$r+�r1zwait.<locals>.<setcomp>)r�isfuturerr?rA�typerw�
ValueErrorrrrrr�warnings�warn�DeprecationWarning�set�any�_wait)�fsr"r}r~r#r!r$rus$
��rcGs|��s|�d�dSr)r'rZ)�waiter�argsr#r#r$�_release_waiter�sr�r!c
�s�|durt��}ntjdtdd�|dur4|IdHS|dkr�t||d�}|��rX|��St||d�IdHz
|��WSt	j
y�}zt	��|�WYd}~n
d}~00|��}|�
|t|�}t�t|�}t||d�}|�|�z�z|IdHWnTt	j
�yB|���r |��YW|��S|�|�t||d�IdH�Yn0|���r`|��W|��S|�|�t||d�IdHz|��WW|��St	j
�y�}zt	��|�WYd}~n
d}~00W|��n
|��0dS)Nrr�r�rr!)rrr�r�r�rr'rY�_cancel_and_waitrrh�TimeoutError�
create_future�
call_laterr��	functools�partialrqrd�remove_done_callback)�futr}r"rtr��timeout_handle�cbr#r#r$r�sZ

�

 

�

�

�"rc
�s�|���d�|dur"|�|t���t|������fdd�}|D]}|�|�q@z2�IdHW�durn���|D]}|�|�qrn&�dur����|D]}|�|�q�0t�t�}}|D]"}|��r�|�	|�q�|�	|�q�||fS)NcsZ�d8��dks4�tks4�tkrV|��sV|��durV�durD������sV��d�dS)Nrr)rr�	cancelledr[rdr'rZ�r��Zcounterr~r�r�r#r$�_on_completion�s���
�z_wait.<locals>._on_completion)
r�r�r��lenrqrdr�r�r'�add)r�r}r~r"r�r�r'Zpendingr#r�r$r��s0�r�c	�sP|��}t�t|�}|�|�z |��|IdHW|�|�n|�|�0dSr)r�r�r�r�rqrdr�)r�r"r�r�r#r#r$r�s
r�)r"r}c#s�t�|�st�|�r(tdt|�j�����dur@tjdt	dd�ddl
m}|�d���durft�
���fdd	�t|�D��d����fd
d�}���fdd
���fdd�}�D]}|���q��r�|dur؈�||��tt���D]}|�Vq�dS)Nz#expect an iterable of futures, not rr�r�r)�Queuer!csh|]}t|�d��qSr�r�r�r!r#r$r+Mr1zas_completed.<locals>.<setcomp>cs*�D]}|�����d�q���dSr)r��
put_nowait�clearr�)r�r'�todor#r$�_on_timeoutPs
z!as_completed.<locals>._on_timeoutcs4�sdS��|���|��s0�dur0���dSr)�remover�rdr�)r'r�r�r#r$r�Vs

z$as_completed.<locals>._on_completionc�s$���IdH}|durtj�|��Sr)r rr�rYr�)r'r#r$�
_wait_for_one^sz#as_completed.<locals>._wait_for_one)rr�rr?rAr�rwr�r�r�Zqueuesr�rr2r�rqr��ranger�)r�r"r}r�r�r�r��_r#)r�r'r"r�r�r$r.s*�
rccs
dVdSrr#r#r#r#r$�__sleep0ms	r�c�s~|durtjdtdd�|dkr0t�IdH|S|dur@t��}|��}|�|tj	||�}z|IdHW|�
�S|�
�0dS)Nrr�r�r)r�r�r�r�rrr�r�rZ_set_result_unless_cancelledrd)ZdelayrYr"rv�hr#r#r$r	ys&��
�r	cCs�t�|�r6|durt��}|�|�}|jr2|jd=|St�|�rb|dur^|t�|�ur^t	d��|St
�|�r|tt
|�|d�Std��dS)Nr9zRThe future belongs to a different loop than the one specified as the loop argumentr!z:An asyncio.Future, a coroutine or an awaitable is required)rr?rr2rr>rr�r&r�rsZisawaitabler�_wrap_awaitablerA)Zcoro_or_futurer"r6r#r#r$r�s



rccs|��EdHSr)�	__await__)Z	awaitabler#r#r$r��sr�cs,eZdZdd��fdd�
Zddd�Z�ZS)�_GatheringFutureNr!cst�j|d�||_d|_dS)Nr!F)r<r=�	_children�_cancel_requested)rM�childrenr"rOr#r$r=�sz_GatheringFuture.__init__cCs:|��rdSd}|jD]}|j|d�rd}q|r6d|_|Sra)r'r�rdr�)rMrcZret�childr#r#r$rd�s
z_GatheringFuture.cancel)N)rwrxryr=rdr|r#r#rOr$r��sr�F�r"�return_exceptionscGs(|durtjdtdd�t|||d��S)Nrr�r�r�)r�r�r��_gather)r"r��coros_or_futuresr#r#r$r
�s
�r
cs�|s*|durt��}|�����g��S�����fdd�}i}g�d�d�d�|D]f}||vr�t||d�}|dur�t�|�}||ur�d|_�d7�|||<|�|�n||}��	|�qVt
�|d���S)Ncs��d7��dus���r,|��s(|��dS�sl|��rN|��}��|�dS|��}|durl��|�dS��kr�g}�D]J}|��r�t�|jdur�dn|j�}n|��}|dur�|��}|�	|�q|�j
r�|��}��|�n
��|�dS)Nr�)r'r�r[rir\rrhrerY�appendr�rZ)r�rtZresults�res�r�Z	nfinishedZnfuts�outerr�r#r$�_done_callback�s<

�z_gather.<locals>._done_callbackrr!Fr)rr2r�rZrrr&r@rqr�r�)r"r�r�r�Z
arg_to_fut�argr�r#r�r$r��s4
7
r�cst|durtjdtdd�t||d�����r0�St���}|����fdd����fdd�}������|��S)	Nrr�r�r!cs\���r|��s|��dS|��r.���n*|��}|durJ��|�n��|���dSr)r�r[rdr\rZrY)�innerrt�r�r#r$�_inner_done_callbackzs
z$shield.<locals>._inner_done_callbackcs���s����dSr)r'r�r�)r�r�r#r$�_outer_done_callback�sz$shield.<locals>._outer_done_callback)	r�r�r�rr'rr&r�rq)r�r"r�r#)r�r�r�r$rUs�


rcs:t���std��tj������fdd�}��|��S)NzA coroutine object is requiredc
slzt�t��d���WnNttfy0�Yn8tyf}z ���rP��|��WYd}~n
d}~00dS)Nr!)rZ
_chain_futurerrnrmroZset_running_or_notify_cancelr\)rt�rNrvr"r#r$�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rr?rA�
concurrentr�FutureZcall_soon_threadsafe)rNr"r�r#r�r$r
�s



r
cCst�|�dSr)r-r��r6r#r#r$r�srcCs4t�|�}|dur(td|�d|�d���|t|<dS)NzCannot enter into task z while another task z is being executed.�rr r.�r"r6rr#r#r$r�s

�
rcCs2t�|�}||ur(td|�d|�d���t|=dS)Nz
Leaving task z! does not match the current task �.r�r�r#r#r$r�s

�
rcCst�|�dSr)r-�discardr�r#r#r$r�sr)rrrrr-r)N)N)N)N)C�__all__Zconcurrent.futuresr�rHr�rs�	itertools�typesr��weakrefrr�rrrrrr�count�__next__rBrrr3r8Z	_PyFuturerZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrr�rr�r�r�	coroutiner�r	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_taskr#r#r#r$�<module>s�	



u

+L,?

&^?$