Vc  dZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZejdjZd,d Zd,d Zd ZGddejZeZ ddlZejxZZn #e$rYnwxYwddddZejjZejj Z ejj!Z!de!ddZ"dZ#dZ$dZ%dZ&dddZ'ej(dZ)d,dZ*dddZ+dddZ,ej(dZ-ee-_Gd d!ej.Z/d"d#d$Z0d%Z1d&Z2e j3Z4iZ5d'Z6d(Z7d)Z8d*Z9e6Z:e9Z;e7Ze9Z?e7Z@e8ZAdS#e$rYdSwxYw)-)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) GenericAlias) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecV |tj}tj|SN)rget_running_loop_current_tasksgetloops &/usr/lib64/python3.11/asyncio/tasks.pyrr#s,+ )&((  d # ##c tjd} tt}n#t$r|dz }|dkrYnwxYw3fd|DS)NrTrichh|].}tj|u|,|/S)r _get_loopdone).0tr$s r% zall_tasks..=sM > > >! ##t+ >45FFHH >A > > >r&)rr list _all_tasks RuntimeError)r$itaskss` r%rr*s1 )&(( A $$E      FADy     > > > >u > > >>s1A  A c|B |j}||dS#t$r tjdtdYdSwxYwdS)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13. stacklevel)set_nameAttributeErrorwarningswarnDeprecationWarning)tasknamer8s r%_set_task_namer?As  }H HTNNNNN  8 8 8 M9)Q 8 8 8 8 8 8 8 8  s&AAceZdZ dZddddfd ZfdZeeZdZ dZ dZ d Z d Z d Zdd d ZddddZddZdZdZdfd ZdZxZS)rTN)r$r>contextct||jr|jd=tj|sd|_t d||dt|_nt||_d|_ d|_ d|_ ||_ |tj|_n||_|j|j|jt)|dS)Nr#Fza coroutine was expected, got zTask-rrA)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr_num_cancels_requested _must_cancel _fut_waiter_coro contextvars copy_context_context_loop call_soon _Task__stepr)selfcoror$r>rA __class__s r%rFz Task.__init__`s  d###  ! +&r*%d++ G).D %ETEEFF F  #7!3!5!577DJJTDJ&'#!  $'466DMM#DM T[$-@@@tr&c|jtjkr7|jr0|dd}|jr |j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r=messagesource_traceback) _stater_PENDINGrIrGrUcall_exception_handlerrE__del__)rXrArZs r%raz Task.__del__{s} ;'* * 7t/H 7BG% E.2.D*+ J - -g 6 6 6 r&c*tj|Sr)r _task_reprrXs r%__repr__z Task.__repr__s$T***r&c|jSr)rQrds r%get_coroz Task.get_coro zr&c|jSr)rLrds r%get_namez Task.get_namerhr&c.t||_dSr)rMrL)rXvalues r%r8z Task.set_namesZZ r&c td)Nz*Task does not support set_result operationr1)rXresults r% set_resultzTask.set_resultsGHHHr&c td)Nz-Task does not support set_exception operationrn)rX exceptions r% set_exceptionzTask.set_exceptionsJKKKr&)limitc. tj||Sr)r_task_get_stack)rXrts r% get_stackzTask.get_stacks ()$666r&)rtfilec0 tj|||Sr)r_task_print_stack)rXrtrxs r% print_stackzTask.print_stacks +D%>>>r&c d|_|rdS|xjdz c_|j|j|rdSd|_||_dS)NFrmsgT)_log_tracebackr+rNrPcancelrO_cancel_message)rXr~s r%rz Task.cancels *$ 99;; 5 ##q(##   &&3&// t "tr&c |jSrrNrds r% cancellingzTask.cancellings **r&cH |jdkr|xjdzc_|jS)Nrrrrds r%uncancelz Task.uncancels6   & * -  ' '1 , ' '**r&c|rtjd|d||jr5t |tjs|}d|_|j}d|_t|j | || d}n| |}t|dd}|8tj||j ur?t!d|d|d}|j |j||jn|r||ur;t!d |}|j |j||jnnd|_||j|j||_|jr'|j|j rd|_nt!d |d |}|j |j||jn|(|j |j|jnt3j|r>t!d |d |}|j |j||jnUt!d|}|j |j||jn#t6$rf}|jr/d|_t9|j n&t9|jYd}~nd}~wtj$r1}||_t9Yd}~nqd}~wt@tBf$r'}t9"|d}~wtF$r+}t9"|Yd}~nd}~wwxYwtI|j |d}dS#tI|j |d}wxYw)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different looprDzTask cannot await on itself: r}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+rInvalidStateErrorrO isinstanceCancelledError_make_cancelled_errorrQrPrrUsendthrowgetattrrr*r1rVrWrTradd_done_callback _Task__wakeuprrinspect isgenerator StopIterationrErprl_cancelled_excKeyboardInterrupt SystemExitrs BaseExceptionr)rXexcrYroblockingnew_excrZs r%__stepz Task.__steps 99;; =.;$;;C;;== =   &c:#<== 30022 %D zDJ%%%H  )4C$v'A4HHH, A$V,,DJ>E*CCC!CCCDDGJ(( Wdm)EEEEE~ :".DDDD#F#F ,, K$--IIII;@700 M4=1BBB+1(,:#/66(,(< 7 > >:49 1*<#'<<17<<==GJ(( Wdm)EEEE A $$T[$-$HHHH$V,, A&B)-BB7=BBCC $$K$-%AAAA''Hf'H'HII $$K$-%AAAA{ . . .  .$)!4#78888""39---(   "%D  GGNN        !:.    GG ! !# & & &  ' ' ' GG ! !# & & & & & & & & 'd  D ) ) )DDD  D ) ) )DKKKKsb-K=HO3 O AL+&O3+O='M)$O3)O="N O,!O O3OO33P c ||n,#t$r}||Yd}~nd}~wwxYwd}dSr)rorWr)rXfuturers r%__wakeupz Task.__wakeupQsr  MMOOO KKMMMM    KK         s+ AAAr)__name__ __module__ __qualname__rIrFra classmethodr__class_getitem__rergrjr8rprsrwr{rrrrWr __classcell__rZs@r%rrNs+ %)d6     $ L11+++   IIILLL"&77777.$(d ? ? ? ? ?((((T+++ + + +UUUUUUnr&r)r>rAc tj}|||}n|||}t|||S)NrD)rr rr?)rYr>rAr$r=s r%rrnsa  " $ $D7%%g664 Kr&)timeout return_whencK tj|stj|r$t dt |j|std|tttfvrtd|t|}td|Drt dtj}t||||d{VS)Nzexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3>K|]}tj|VdSr)rrH)r,fs r% zwait..s- 1 1: !! $ $ 1 1 1 1 1 1r&z6Passing coroutines is forbidden, use tasks explicitly.)risfuturerrHrJtyper ValueErrorrrrsetanyrr _wait)fsrrr$s r%rrsNz5b99NLb9JLLMMM ;9:::?O]KKFD{DDEEE RB 1 1b 1 1 111RPQQQ  " $ $Dr7K66 6 6 6 6 6 66r&c\|s|ddSdSr)r+rp)waiterargss r%_release_waiterrs6 ;;== $  r&c K tj}||d{VS|dkrt||}|r|St ||d{V |S#t j$r}t j|d}~wwxYw| }| |t|}tj t|}t||}|| |d{Vn~#t j$rl|r*|cY|S||t ||d{VwxYw|r(||S||t ||d{V ||S#t j$r}t j|d}~wwxYw#|wxYw)Nrr#)rr r r+ro_cancel_and_waitrr TimeoutError create_future call_laterr functoolspartialrrremove_done_callback)futrr$rrtimeout_handlecbs r%rrs   " $ $Dyyyyyy!| 5Cd+++ 88:: ::<< s.......... 5::<< ( 5 5 5)++ 4 5   ! !F__WovFFN  ?F 3 3B $ ' ' 'C"  LLLLLLLL(   xxzz zz||##2 /((,,,'s6666666666  88:: 9::<<   $ $R ( ( (#3T222 2 2 2 2 2 2 2 9zz|| , 9 9 9 -//S8 9 sf8B B4B//B4)D21I,27F-)I,?.F--*I,,,I,II)I$$I))I,,Jc K | d |||t  t| fd}|D]}|| d{V  |D]}||n5#  |D]}||wxYwtt}}|D]A}|r| |,| |B||fS)Nc(dzdks>tks3tkri|sW|EsddSdSdSdSdS)Nrr)rr cancelledrrrr+rp)rcounterrrrs r%_on_completionz_wait.._on_completions1  qL ( ? * ( ? * (45KKMM (12  ( (%%''';;== (!!$''''' ( ( ( ( ( (  ( (r&) rrrlenrrrrr+add) rrrr$rrr+pendingrrrs ` @@@r%rrs    ! !FNK/6JJ"ggG ( ( ( ( ( ( ( (,, N++++3  $  ! ! # # # 3 3A " "> 2 2 2 2 3  $  ! ! # # # 3 3A " "> 2 2 2 2 3EE355'D  6688  HHQKKKK KKNNNN =s .B''2Cc*K |}tjt|}|| ||d{V||dS#||wxYwr)rrrrrrr)rr$rrs r%rrsF    ! !F  ?F 3 3B"%     $$$$$  $$$$s A;;B)rc# K tj|stj|r$t dt |jddlm}|tj fdt|D d  fd} fdfd} D]}|  r| || tt D]}|VdS)Nz#expect an iterable of futures, not r)Queuec2h|]}t|S)r#)r )r,rr$s r%r.zas_completed..Gs& 9 9 9AM!$ ' ' ' 9 9 9r&cD],}|d-dSr)r put_nowaitclear)rrr+todos r% _on_timeoutz!as_completed.._on_timeoutJsL " "A " "> 2 2 2 OOD ! ! ! ! r&csdS||sdSdSdSr)removerr)rr+rrs r%rz$as_completed.._on_completionPsl  F A  $ $  ! ! # # # # # $ $ $ $r&cKd{V}| tj|Sr)r"rrro)rr+s r% _wait_for_onez#as_completed.._wait_for_oneXsE((**        *) )xxzzr&)rrrrHrJrrqueuesrr_get_event_looprrrranger) rrrrrr_rr+r$rrs @@@@@r%r r .s"Sz5b99SQd2hh>OQQRRR 577D  ! # #D 9 9 9 9R 9 9 9DN $$$$$$$,, N++++ ??+>> 3t99  moor&c#K dVdSrr)r)r&r%__sleep0rgs EEEEEr&c@K |dkrtd{V|Stj}|}||t j||} |d{V |S#|wxYw)Nr)rrr rrr_set_result_unless_cancelledr)delayror$rhs r%r r ssC zjj  " $ $D    ! !F < ( (A||||||   s *BBr#c& t||SNr#)_ensure_future)coro_or_futurer$s r%r r s .t 4 4 44r&ctj|r)|%|tj|urtd|Sd}t j|s5t j|rt|}d}ntd|tj d} | |S#t$r|s|wxYw)NzRThe future belongs to a different loop than the one specified as the loop argumentFTz:An asyncio.Future, a coroutine or an awaitable is requiredr6)rrr*rrrHr isawaitable_wrap_awaitablerJrrrr1close)rr$called_wrap_awaitables r%rrs''  FG,=n,M,M M FEFF F!  !. 1 1+  ~ . . +,^<tj}| g S fd}i}gd dd}d |D]u}||vrRt ||}|t j|}||urd|_ dz |||<||n||} |vt| S)Ncdz r*|s|dSsl|r+|}|dS|}||dSkrg}D]x}|r#t j|jdn|j}n*|}||}| |yj r+|}|dS |dSdS)Nr) r+rrrrrsrrrroappendrrp) rrresultsresr nfinishednfutsouterrs r%_done_callbackzgather.._done_callbacksQ  EJJLL ==??   F }} //11##C(((mmoo'',,,F   *G $ $==?? +%3!1,+--CC--//C+!jjlls####& *//11##C(((((  ))))); * *r&rr#Fr) rrrrprrr*rIrrr) rcoros_or_futuresr$r arg_to_futargrrrrrs ` @@@@r%r r sX: %''""$$  5*5*5*5*5*5*5*5*5*nJH EI D E j  " 4000C .(--#~ 1 ,1( QJE!JsO  ! !. 1 1 1 1S/C XD 1 1 1E Lr&c t|rStj}|fdfd}|S)Ncr*|s|dS|rdS|}||dS|dSr)rrrrrsrpro)innerrrs r%_inner_done_callbackz$shield.._inner_done_callbackqs ??   ??$$ "!!! F ??   1 LLNNNNN//##C 1##C(((((  00000r&c^sdSdSr)r+r)rr r s r%_outer_done_callbackz$shield.._outer_done_callbacks8zz|| =  & &'; < < < < < = =r&)rr+rr*rr)rr$r r r rs @@@r%r r Is@ 3  E zz||  U # #D    E11111"====== 0111 0111 Lr&c tjstdtjfd}|S)NzA coroutine object is requiredc tjtdS#ttf$rt $r/}r|d}~wwxYwr)r _chain_futurer rrrset_running_or_notify_cancelrs)rrYrr$s r%callbackz*run_coroutine_threadsafe..callbacks   !-4"@"@"@& I I I I I-.       2244 *$$S)))  s$)A3*A..A3)rrHrJ concurrentrFuturecall_soon_threadsafe)rYr$rrs`` @r%rrs  !$ ' ':8999   & & ( (F h''' Mr&c0 tj|dSr)r0rr=s r%rrs=N4r&crtj|}|td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.r!r"r1r$r=rs r%rrsi!%d++LHGTGG#/GGGHH HN4r&crtj|}||urtd|d|dt|=dS)Nz Leaving task z! does not match the current task .rrs r%rrsl!%d++L4BA4AA/;AAABB Btr&c0 tj|dSr)r0discardrs r%rrstr&)rrrrr0r!r)B__all__concurrent.futuresrrRrr itertoolstypesr:weakrefrrrrrrrrcount__next__rKrrr? _PyFuturer_PyTask_asyncio_CTask ImportErrorrrrrrrrrrr coroutinerr r rrrrr r rWeakSetr0r!rrrr_py_register_task_py_unregister_task_py_enter_task_py_leave_task_c_register_task_c_unregister_task _c_enter_task _c_leave_taskr)r&r%r4sv6  %%%%%% %Y_Q''0$$$$>>>>.   QQQQQ7 QQQh "OOO M!D66    D #D     $$4$4"0 # 77777@   D D D N)))X % % %"!%66666r   "+/55555,02...!.w~:16xxxxxv???D0W_        #&  6666666666666666 &)MMMM    DD s$BBBE77F?F