Vc cs 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_coroutinecsV |tj}tj|SN)rget_running_loop_current_tasksgetloop &/usr/lib64/python3.11/asyncio/tasks.pyr r #s,+ )&((  d # ##cs tjd} tt}n#t$r|dz }|dkrYnwxYw3fd|DS)NrTricshh|].}tj|u|,|/S)r _get_loopdone).0Ztr! r# zall_tasks..=sM > > >! ##t+ >45FFHH >A > > >r$)rrZlist _all_tasks RuntimeError)r!ZiZtaskss` r#rr*s1 )&(( A $$E      FADy     > > > >u > > >>s1A  A cs|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.iZ stacklevel)set_nameZAttributeErrorwarningsZwarnZDeprecationWarning)tasknamer. r#_set_task_namer3As  }H HTNNNNN  8 8 8 M9)Q 8 8 8 8 8 8 8 8  s&AAcseZdZ dZddddfd ZfdZeeZdZ dZ dZ d Z d Z d Zdd d ZddddZddZdZdZdfd ZdZxZS)rTN)r!r1contextcst||jr|jd=tj|sd|_t d||dt|_nt||_d|_ d|_ d|_ ||_ |tj|_n||_|j|j|jt)|dS)Nr iFza coroutine was expected, got zTask-rr4)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr_num_cancels_requested _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror!r1r4 __class__s r#r7z Task.__init__`s  d###  ! +&r*%d++ G).D %ETEEFF F  #7!3!5!577DJJTDJ&'#!  $'466DMM#DM T[$-@@@tr$cs|jtjkr7|jr0|dd}|jr |j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r0ZmessageZsource_traceback) Z_staterZ_PENDINGr:r8rEZcall_exception_handlerr6__del__)rHr4rJr)r#rKz Task.__del__{s} ;'* * 7t/H 7BG% E.2.D*+ J - -g 6 6 6 r$cs*tj|Sr)rZ _task_reprrHr"r#__repr__z Task.__repr__s$T***r$c|jSr)rBrLr"r#get_coroz Task.get_coro zr$crNr)r=rLr"r#get_namez Task.get_namerPr$cs.t||_dSr)r>r=)rHvalue r#r.z Task.set_namesZZ r$c td)Nz*Task does not support set_result operationr,)rHresultrSr# set_resultzTask.set_resultsGHHHr$crT)Nz-Task does not support set_exception operationrU)rH exceptionrSr# set_exceptionzTask.set_exceptionsJKKKr$)limitcs. tj||Sr)rZ_task_get_stack)rHrZrSr# get_stackzTask.get_stacks ()$666r$)rZfilecs0 tj|||Sr)rZ_task_print_stack)rHrZr\r2r# print_stackzTask.print_stacks +D%>>>r$cs d|_|rdS|xjdz c_|j|j|rdSd|_||_dS)NFrmsgT)Z_log_tracebackr'r?rAcancelr@_cancel_message)rHr_rSr#r`z Task.cancels *$ 99;; 5 ##q(##   &&3&// t "tr$cs |jSrr?rLr"r# cancellingzTask.cancellings **r$csH |jdkr|xjdzc_|jS)NrrrbrLr"r#uncancelz Task.uncancels6   & * -  ' '1 , ' '**r$cs|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 loopr5zTask 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'rZInvalidStateErrorr@Z isinstanceCancelledError_make_cancelled_errorrBrArrEZsendZthrowZgetattrrr&r,rFrGrDreadd_done_callback _Task__wakeupr`rainspectZ isgeneratorZ StopIterationr6rWrRZ_cancelled_excKeyboardInterrupt SystemExitrY BaseExceptionr)rHexcrIrVZblockingZnew_excrJs r#Z__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 cs ||n,#t$r}||Yd}~nd}~wwxYwd}dSr)rVrGrm)rHfuturernr2r#Z__wakeupz Task.__wakeupQsr  MMOOO KKMMMM    KK         s+ AAAr)__name__ __module__ __qualname__r:r7rKZ classmethodrZ__class_getitem__rMrOrQr.rWrYr[r]r`rcrdrGri __classcell__rJ@r#rrNs+ %)d6     $ L11+++   IIILLL"&77777.$(d ? ? ? ? ?((((T+++ + + +UUUUUUnr$r)r1r4cs tj}|||}n|||}t|||S)Nr5)rrrr3)rIr1r4r!r0 r#rrnsa  " $ $D7%%g664 Kr$)timeout return_whencsK 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: c3s>K|]}tj|VdSr)rr9)r(frSr#z zwait..s- 1 1: !! $ $ 1 1 1 1 1 1r$z6Passing coroutines is forbidden, use tasks explicitly.)risfuturerr9r;typerp ValueErrorrrrsetZanyrr_wait)fsrwrxr! r#rrsNz5b99NLb9JLLMMM ;9:::?O]KKFD{DDEEE RB 1 1b 1 1 111RPQQQ  " $ $Dr7K66 6 6 6 6 6 66r$cs\|s|ddSdSr)r'rW)waiterZargsrSr#_release_waiterrs6 ;;== $  r$cs 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 )rrr r'rV_cancel_and_waitrrf TimeoutError create_future call_laterr functoolspartialrhr`remove_done_callback)futrwr!rnrtimeout_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,,Jcs K | d |||t  t| fd}|D]}|| d{V  |D]}||n5#  |D]}||wxYwtt}}|D]A}|r| |,| |B||fS)Ncs(dzdks>tks3tkri|sW|EsddSdSdSdSdS)Nrr)rr cancelledrXr`r'rW)rycounterrxrrs r#_on_completionz_wait.._on_completions1  qL ( ? * ( ? * (45KKMM (12  ( (%%''';;== (!!$''''' ( ( ( ( ( (  ( (r$) rrrlenrhr`rr}r'add) rrwrxr!rryr'Zpendingrrrs ` @@@r#r~r~s    ! !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''2Ccs*K |}tjt|}|| ||d{V||dS#||wxYwr)rrrrrhr`r)rr!rrrr#rrsF    ! !F  ?F 3 3B"%     $$$$$  $$$$s A;;B)rwc#s 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)Queuecs2h|]}t|S)r )r )r(ryr!r)r#r*zas_completed..Gs& 9 9 9AM!$ ' ' ' 9 9 9r$csD],}|d-dSr)r put_nowaitZclear)ryrr'todo r# _on_timeoutz!as_completed.._on_timeoutJsL " "A " "> 2 2 2 OOD ! ! ! ! r$cssdS||sdSdSdSr)Zremoverr`)ryr'rrrr#rz$as_completed.._on_completionPsl  F A  $ $  ! ! # # # # # $ $ $ $r$csKd{V}| tj|Sr)rrrrV)ryr's r# _wait_for_onez#as_completed.._wait_for_oneXsE((**        *) )xxzzr$)rrzrr9r;r{rpZqueuesrr_get_event_loopr}rhrZranger) rrwrrrryZ_rr'r!rrs @@@@@r#rr.s"Sz5b99SQd2hh>OQQRRR 577D  ! # #D 9 9 9 9R 9 9 9DN $$$$$$$,, N++++ ??+>> 3t99  moor$c#sK dVdSrr%r%r$r#__sleep0rgs EEEEEr$cs@K |dkrtd{V|Stj}|}||t j||} |d{V |S#|wxYw)Nr)rrrrrrZ_set_result_unless_cancelledr`)ZdelayrVr!roZhrvr#rrssC zjj  " $ $D    ! !F < ( (A||||||   s *BBr cs& t||SNr )_ensure_future)coro_or_futurer!rSr#r r s .t 4 4 44r$cstj|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 requiredir-)rrzr&r|rr9rjZ isawaitable_wrap_awaitabler;rrrr,Zclose)rr!Zcalled_wrap_awaitabler2r#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)Ncsdz r*|s|dSsl|r+|}|dS|}||dSkrg}D]x}|r#t j|jdn|j}n*|}||}| |yj r+|}|dS |dSdS)Nr) r'rrXrgrYrrfrarVappendrrW) rrnZresultsZresr nfinishednfutsouterrs r#_done_callbackzgather.._done_callbacksQ  EJJLL ==??   F }} //11##C(((mmoo'',,,F   *G $ $==?? +%3!1,+--CC--//C+!jjlls####& *//11##C(((((  ))))); * *r$rr Fr) rrrrWrrr&r:rhrr) rZcoros_or_futuresr!rZ 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$cs t|rStj}|fdfd}|S)Ncsr*|s|dS|rdS|}||dS|dSr)rrXr`rYrWrV)innerrnrr)r#_inner_done_callbackz$shield.._inner_done_callbackqs ??   ??$$ "!!! F ??   1 LLNNNNN//##C 1##C(((((  00000r$cs^sdSdSr)r'r)rrrs r#_outer_done_callbackz$shield.._outer_done_callbacks8zz|| =  & &'; < < < < < = =r$)rr'rr&rrh)rr!rrrrs @@@r#r r Is@ 3  E zz||  U # #D    E11111"====== 0111 0111 Lr$cs tjstdtjfd}|S)NzA coroutine object is requiredcs tjtdS#ttf$rt $r/}r|d}~wwxYwr)rZ _chain_futurer rlrkrmZset_running_or_notify_cancelrY)rnrIror!rr#callbackz*run_coroutine_threadsafe..callbacks   !-4"@"@"@& I I I I I-.       2244 *$$S)))  s$)A3*A..A3)rr9r; concurrentrFutureZcall_soon_threadsafe)rIr!rros`` @r#r r s  !$ ' ':8999   & & ( (F h''' Mr$c0 tj|dSr)r+rr0r"r#rrs=N4r$csrtj|}|td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr,r!r0r r2r#rrsi!%d++LHGTGG#/GGGHH HN4r$csrtj|}||urtd|d|dt|=dS)Nz Leaving task z! does not match the current task z.rrr2r#rrsl!%d++L4BA4AA/;AAABB Btr$crr)r+Zdiscardrr"r#rrstr$)rrrrr+rr)BZ__all__Zconcurrent.futuresrrCrrjZ itertoolsZtypesr/ZweakrefrrrrrrrrZcountZ__next__r<r rr3Z _PyFuturerZ_PyTaskZ_asyncioZ_CTaskZ ImportErrorrrrrrrrr~rrZ coroutinerrr rrrrr 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#rsv6  %%%%%% %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