a XC?hs†ã@sŒdZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZe d¡jZdDd d „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:Zz$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$Ú =sÿzall_tasks..)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..)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 „Z dd„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 z Task.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ÚinspectZ isgeneratorr)rMÚexcrNrYZblockingÚnew_excrOr#r$Z__stepïs°ÿ   $  $  ÿÿ ÿ ÿ ÿÿÿÿÿÿ ÿ  ÿÿÿ ÿ ÿ ÿ z Task.__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$Ú •r1zwait..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..)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.._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..cs*ˆD]}| ˆ¡ˆ d¡qˆ ¡dSr)r›Ú put_nowaitÚclearr )r¢r'Útodor#r$Ú _on_timeoutPs  z!as_completed.._on_timeoutcs4ˆsdSˆ |¡ˆ |¡ˆs0ˆdur0ˆ ¡dSr)Úremover¦rdr )r'r�r¨r#r$r¢Vs    z$as_completed.._on_completionc“s$ˆ ¡IdH}|durtj‚| ¡Sr)r rr–rYr )r'r#r$Ú _wait_for_one^sz#as_completed.._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ŠrsZ isawaitabler Ú_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.._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.._inner_done_callbackcsˆ ¡sˆ ˆ¡dSr)r'r›rÃ)rÄrÂr#r$Ú_outer_done_callback‹sz$shield.._outer_done_callback) r‹rŒr�r r'rr&r—rq)rÁr"rÅr#)rÄrÂr¿r$r Usþ     r cs: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..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¹r r 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$Úsˆ             u   +L,?  &^?$