ok

Mini Shell

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

U

.��c���@srdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	lmZe�d�jZdAd
d�ZdBdd
�ZdCdd�Zdd�ZGdd�dej�ZeZzddlZWnek
r�YnXejZZdd�dd�ZejjZejj Z ejj!Z!dde!d�dd�Z"dd�Z#dd�dd�Z$dd �Z%d!d"�Z&ddd#�d$d%�Z'ej(d&d'��Z)dDdd�d(d)�Z*dd�d*d+�Z+ej(d,d-��Z,ee,_Gd.d/�d/ej-�Z.dd0d1�d2d3�Z/dd�d4d5�Z0d6d7�Z1e	�2�Z3iZ4d8d9�Z5d:d;�Z6d<d=�Z7d>d?�Z8e5Z9e8Z:e6Z;e7Z<z$dd@lm5Z5m8Z8m6Z6m7Z7m3Z3m4Z4Wnek
�r\YnXe5Z=e8Z>e6Z?e7Z@dS)E)�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)�
exceptions)�futures)�
_is_coroutinecCs|dkrt��}t�|�S�N)r�get_running_loop�_current_tasks�get��loop�r"�2/opt/alt/python38/lib64/python3.8/asyncio/tasks.pyr"srcs^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)Nrr��cs&h|]}t�|��kr|��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^�dkrt���d}ztt�}WqLtk
rF|d7}|dkrB�YqXqLq�fdd�|D�S)Nrrr$csh|]}t�|��kr|�qSr")rr%r'r r"r#r*Usz$_all_tasks_compat.<locals>.<setcomp>)r�get_event_loopr+r,r-r.r"r r#�_all_tasks_compat@sr1cCs4|dk	r0z
|j}Wntk
r&Yn
X||�dSr)�set_name�AttributeError)�task�namer2r"r"r#�_set_task_nameXs
r6cs�eZdZdZed$dd��Zed%dd��Zddd��fdd	�
Z�fd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�dd�Zddd�dd�Zdd�Zd&�fd d!�	Zd"d#�Z�ZS)'rTNcCs(tjdtdd�|dkr t��}t|�S)NzVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead���
stacklevel)�warnings�warn�DeprecationWarningrr0r��clsr!r"r"r#rts�zTask.current_taskcCstjdtdd�t|�S)NzPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r1r=r"r"r#r�s
�zTask.all_tasks)r!r5cs�t�j|d�|jr|jd=t�|�s:d|_td|����|dkrRdt���|_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!r5��	__class__r"r#rC�s


z
Task.__init__csF|jtjkr8|jr8|dd�}|jr,|j|d<|j�|�t���dS)Nz%Task was destroyed but it is pending!)r4�messageZsource_traceback)	Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB�__del__)rSrArUr"r#rX�s�
zTask.__del__cCs
t�|�Sr)rZ_task_repr_info�rSr"r"r#�
_repr_info�szTask._repr_infocCs|jSr)rMrYr"r"r#�get_coro�sz
Task.get_corocCs|jSr)rIrYr"r"r#�get_name�sz
Task.get_namecCst|�|_dSr)rJrI)rS�valuer"r"r#r2�sz
Task.set_namecCstd��dS)Nz*Task does not support set_result operation�r-)rS�resultr"r"r#�
set_result�szTask.set_resultcCstd��dS)Nz-Task does not support set_exception operationr^)rS�	exceptionr"r"r#�
set_exception�szTask.set_exception)�limitcCst�||�Sr)rZ_task_get_stack)rSrcr"r"r#�	get_stack�szTask.get_stack)rc�filecCst�|||�Sr)rZ_task_print_stack)rSrcrer"r"r#�print_stack�s	zTask.print_stackcCs4d|_|��rdS|jdk	r*|j��r*dSd|_dS�NFT)Z_log_tracebackr&rL�cancelrKrYr"r"r#rh�s

zTask.cancelc
s�|��rt�d|�d|����|jr>t|tj�s8t��}d|_|j}d|_t|j	|��zfz"|dkrp|�d�}n
|�|�}Wn�t
k
r�}z*|jr�d|_t���nt��|j�W5d}~XY�n�tjk
r�t���Y�n�ttfk
�r}zt��|��W5d}~XY�n�tk
�rL}zt��|�W5d}~XY�npXt|dd�}|dk	�r@t�|�|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�r`|j	j|j|jd�n\t �!|��r�td|�d|���}|j	j|j||jd�n$td
|���}|j	j|j||jd�W5t
|j	|�d}XdS)Nz_step(): already done: z, F�_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&rZInvalidStateErrorrK�
isinstance�CancelledErrorrMrLrrPr�send�throw�
StopIterationrBrhr`r]�KeyboardInterrupt�
SystemExitrb�
BaseException�getattrrr%r-rQrRrOri�add_done_callback�
_Task__wakeup�inspectZisgenerator)rS�excrTr_Zblocking�new_excrUr"r#Z__steps��  
��
�����
���
zTask.__stepc
CsJz|��Wn,tk
r8}z|�|�W5d}~XYn
X|��d}dSr)r_rqrR)rS�futurervr"r"r#Z__wakeup[sz
Task.__wakeup)N)N)N)�__name__�
__module__�__qualname__rF�classmethodrrrCrXrZr[r\r2r`rbrdrfrhrRrt�
__classcell__r"r"rUr#rbs$!Tr)r5cCs t��}|�|�}t||�|Sr)rrrr6)rTr5r!r4r"r"r#rxs

r)r!�timeout�return_whenc�s�t�|�st�|�r(tdt|�j����|s4td��|tt	t
fkrPtd|�����dkrbt���nt
jdtdd��fdd�t|�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.r7r8csh|]}t|�d��qS�r �r�r(�fr r"r#r*�szwait.<locals>.<setcomp>)r�isfuturerrErG�typery�
ValueErrorrrrrrr:r;r<�set�_wait)�fsr!r~rr"r r#r�s
�rcGs|��s|�d�dSr)r&r`)�waiter�argsr"r"r#�_release_waiter�sr�r c
�s�|dkrt��}ntjdtdd�|dkr4|IdHS|dkr�t||d�}|��rX|��St||d�IdHz|��Wn.t	j
k
r�}zt	��|�W5d}~XYn
Xt	���|��}|�
|t|�}t�t|�}t||d�}|�|�z�z|IdHWnPt	j
k
�rF|���r$|��YW�dS|�|�t||d�IdH�YnX|���r^|��W�*S|�|�t||d�IdHt	���W5|��XdS)Nr�r7r8rr )rrr:r;r<rr&r_�_cancel_and_waitrrk�TimeoutError�
create_future�
call_laterr��	functools�partialrsrh�remove_done_callback)�futr~r!rvr��timeout_handle�cbr"r"r#r�sL

�





rc
�s�|���d�|dk	r"|�|t���t|������fdd�}|D]}|�|�q@z�IdHW5�dk	rp���|D]}|�|�qtXt�t�}}|D]"}|��r�|�	|�q�|�	|�q�||fS)NcsZ�d8��dks4�tks4�tkrV|��sV|��dk	rV�dk	rD������sV��d�dS)Nrr)rr�	cancelledrarhr&r`�r��Zcounterrr�r�r"r#�_on_completions���
�z_wait.<locals>._on_completion)
r�r�r��lenrsrhr�r�r&�add)r�r~rr!r�r�r&Zpendingr"r�r#r��s(r�c	�sF|��}t�t|�}|�|�z|��|IdHW5|�|�XdSr)r�r�r�r�rsr�rh)r�r!r�r�r"r"r#r�&s
r�)r!r~c#s�t�|�st�|�r(tdt|�j����ddlm}|�d���dkrPt	�
��ntjdt
dd��fdd	�t|�D��d����fd
d�}���fdd
���fdd�}�D]}|���q��r�|dk	r҈�||��tt���D]}|�Vq�dS)Nz#expect an iterable of futures, not r)�Queuer r�r7r8csh|]}t|�d��qSr�r�r�r r"r#r*Uszas_completed.<locals>.<setcomp>cs*�D]}|�����d�q���dSr)r��
put_nowait�clearr�)r�r&�todor"r#�_on_timeoutXs
z!as_completed.<locals>._on_timeoutcs4�sdS��|���|��s0�dk	r0���dSr)�remover�rhr�)r&r�r�r"r#r�^s

z$as_completed.<locals>._on_completionc�s$���IdH}|dkrtj�|��Sr)rrr�r_r�)r&r"r#�
_wait_for_onefsz#as_completed.<locals>._wait_for_one)rr�rrErGr�ryZqueuesr�rr0r:r;r<r�rsr��ranger�)r�r!r~r�r�r�r��_r")r�r&r!r�r�r#r7s*

�rccs
dVdSrr"r"r"r"r#�__sleep0us	r�c�sr|dkrt�IdH|S|dkr*t��}ntjdtdd�|��}|�|tj	||�}z|IdHW�S|�
�XdS)Nrr�r7r8)r�rrr:r;r<r�r�rZ_set_result_unless_cancelledrh)Zdelayr_r!rx�hr"r"r#r	�s$
��r	cCs�t�|�r6|dkrt��}|�|�}|jr2|jd=|St�|�rb|dk	r^|t�|�k	r^t	d��|St
�|�r|tt
|�|d�Std��dS)Nr?zRThe 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)rrErr0rrDrr�r%r�ruZisawaitabler�_wrap_awaitablerG)Zcoro_or_futurer!r4r"r"r#r�s



rccs|��EdHSr)�	__await__)Z	awaitabler"r"r#r��sr�cs*eZdZdd��fdd�
Zdd�Z�ZS)�_GatheringFutureNr cst�j|d�||_d|_dS)Nr F)rBrC�	_children�_cancel_requested)rS�childrenr!rUr"r#rC�sz_GatheringFuture.__init__cCs6|��rdSd}|jD]}|��rd}q|r2d|_|Srg)r&r�rhr�)rSZretZchildr"r"r#rh�s
z_GatheringFuture.cancel)ryrzr{rCrhr}r"r"rUr#r��sr�F)r!�return_exceptionscs�|s<|dkrt��}ntjdtdd�|�����g��S�����fdd�}i}g�d�d�|D]f}||kr�t||d�}|dkr�t�	|�}||k	r�d|_
�d	7�|||<|�|�n||}��|�qdt
�|d���S)
Nr�r7r8cs��d7����r$|��s |��dS�sd|��rFt��}��|�dS|��}|dk	rd��|�dS��kr�g}�D]8}|��r�t��}n|��}|dkr�|��}|�|�qt�jrĈ�t���n
��	|�dS)Nr)
r&r�rarrkrbr_�appendr�r`)r�rvZresults�res�r�Z	nfinishedZnfuts�outerr�r"r#�_done_callbacks4


zgather.<locals>._done_callbackrr Fr)rr0r:r;r<r�r`rrr%rFrsr�r�)r!r�Zcoros_or_futuresr�Z
arg_to_fut�argr�r"r�r#r
�s:
�
1
r
cst|dk	rtjdtdd�t||d�����r0�St���}|����fdd����fdd�}������|��S)	Nr�r7r8r cs\���r|��s|��dS|��r.���n*|��}|dk	rJ��|�n��|���dSr)r�rarhrbr`r_)�innerrv�r�r"r#�_inner_done_callbackus
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�rs)r�r!r�r")r�r�r�r#rPs�


rcs:t���std��tj������fdd�}��|��S)NzA coroutine object is requiredc
slzt�t��d���WnNttfk
r2�Yn6tk
rf}z���rT��|��W5d}~XYnXdS)Nr )rZ
_chain_futurerrprorqZset_running_or_notify_cancelrb)rv�rTrxr!r"r#�callback�s
z*run_coroutine_threadsafe.<locals>.callback)rrErG�
concurrentr�FutureZcall_soon_threadsafe)rTr!r�r"r�r#r
�s



r
cCst�|�dSr)r,r��r4r"r"r#r�srcCs4t�|�}|dk	r(td|�d|�d���|t|<dS)NzCannot enter into task z while another task z is being executed.�rrr-�r!r4rr"r"r#r�s
rcCs2t�|�}||k	r(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)A�__all__Zconcurrent.futuresr�rNr�ru�	itertools�typesr:�weakref�rrrrrr�count�__next__rHrrr1r6Z	_PyFuturerZ_PyTaskZ_asyncio�ImportErrorZ_CTaskrrrrrr�rr�r�r�	coroutiner�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�	





#H,>

x?$

Zerion Mini Shell 1.0