Ԟ@dZddlmZddlmZddlmZGddZy)) TaskGroup)events) exceptions)taskscXeZdZdZdZdZdZdZdZdddd Z d e d e fd Z d Z dZy)ra9Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. cd|_d|_d|_d|_d|_d|_t |_g|_d|_ d|_ y)NF) _entered_exiting _aborting_loop _parent_task_parent_cancel_requestedset_tasks_errors _base_error_on_completed_futselfs 9/opt/alt/python312/lib64/python3.12/asyncio/taskgroups.py__init__zTaskGroup.__init__sN    (-%e  !%cxdg}|jr'|jdt|j|jr'|jdt|j|jr|jdn|j r|jddj |}d|dS) Nztasks=zerrors= cancellingentered z )rappendlenrr r join)rinfoinfo_strs r__repr__zTaskGroup.__repr__(st ;; KK&T[[!1 23 4 << KK'#dll"3!45 6 >> KK % ]] KK "88D>H:Q''rcK|jrtd|d|jtj|_t j |j|_|jtd|dd|_|Sw)N TaskGroup z has already been enteredz! cannot determine the parent taskT)r RuntimeErrorr rget_running_loopr current_taskr rs r __aenter__zTaskGroup.__aenter__6s ==TH$=>@ @ :: 002DJ!..tzz:    $TH$EFH H  sB B cKd} |j||d{d|_d|_d|_d}S7#d|_d|_d|_d}wxYwwN)_aexitr rr)retexctbs r __aexit__zTaskGroup.__aexit__Dsc  R-- !%D DL#D C. !%D DL#D Cs%A979A9AAcKd|_|$|j|r|j||_|tjur|nd}|j r|j jdk(rd}||js|j|jrT|j|jj|_ |jd{d|_ |jrT|jrJ|j |j |r|js |d}|-|tjur|jj||jr t!d|jdy7#tj$r(}|js|}|jYd}~d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYww)NTzunhandled errors in a TaskGroup)r _is_base_errorrrCancelledErrorrr uncancelr _abortrrr create_futurerrBaseExceptionGroup)rr.r/propagate_cancellation_errorexs rr-zTaskGroup._aexitRs O##C(  ("D 222C %  ( (  ))+q004, >>> kk%%-)-)A)A)C& ",,,,&*D "'kk*;;    ' &&&  0+DLL66,0 ( >b (A(AA LL   $ << (5LL M-,, "~~460KKM "*C+/ (sCGFE>FG/G F>G &G(=G&G=G>FF;F61G6F;;G>GGG  G GGGGN)namecontextc|jstd|d|jr|jstd|d|jrtd|d||j j |}n|j j ||}tj|||jj||j|j |~S#~wxYw)zbCreate a new task in this group and return it. Similar to `asyncio.create_task`. r&z has not been enteredz is finishedz is shutting down)r=) r r'r rr r create_taskr_set_task_nameaddadd_done_callback _on_task_done)rcoror<r=tasks rr?zTaskGroup.create_tasks }}D83HIJ J ==D8<@A A >>D83DEF F ?::))$/D::))$)@D T4(  t112 s &C))C,r/returncRt|tsJt|ttfSr,) isinstance BaseException SystemExitKeyboardInterrupt)rr/s rr4zTaskGroup._is_base_errors%#}---# ,=>??rcvd|_|jD]#}|jr|j%y)NT)r rdonecancel)rts rr7zTaskGroup._aborts)A668 rc|jj||jA|js5|jjs|jj d|j ry|j }|y|jj||j|r|j||_ |jjr1|jjd|d|jd||dy|js?|js2|j!d|_|jj#yyy)NTzTask z% has errored out but its parent task z is already completed)message exceptionrE)rdiscardrrM set_result cancelledrRrrr4rr r call_exception_handlerr rr7rN)rrEr/s rrCzTaskGroup._on_task_dones3 D!  ! ! -dkk))..0&&11$7 >>  nn ;  C   s #(8(8(@"D     ! ! # JJ - -"4(+##'#4#4"55JL  /  ~~d&C&C& KKM,0D )    $ $ &+'D~r)__name__ __module__ __qualname____doc__rr$r*r1r-r?rIboolr4r7rCrrrr sO & (  Wt)-dF@-@D@2'rrN)__all__rrrrrr\rrr^s! @'@'r