Ë
    òT•j+"  ã                   ó@   — d Z ddlmZ ddlmZ ddlmZ  G d„ d«      Zy))Ú	TaskGroupé   )Úevents)Ú
exceptions)Útasksc                   óR   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zdddœd„Zd	e	d
e
fd„Zd„ Zd„ Zy)r   a9  Asynchronous 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`.
    c                 ó    — d| _         d| _        d| _        d | _        d | _        d| _        t        «       | _        g | _        d | _	        d | _
        y )NF)Ú_enteredÚ_exitingÚ	_abortingÚ_loopÚ_parent_taskÚ_parent_cancel_requestedÚsetÚ_tasksÚ_errorsÚ_base_errorÚ_on_completed_fut©Úselfs    ú)/usr/lib/python3.12/asyncio/taskgroups.pyÚ__init__zTaskGroup.__init__   sN   € ØˆŒØˆŒØˆŒØˆŒ
Ø ˆÔØ(-ˆÔ%Ü“eˆŒØˆŒØˆÔØ!%ˆÕó    c                 óx  — dg}| j                   r'|j                  dt        | j                   «      › �«       | j                  r'|j                  dt        | j                  «      › �«       | j                  r|j                  d«       n| j
                  r|j                  d«       dj                  |«      }d|› d�S )	NÚ ztasks=zerrors=Ú
cancellingÚenteredú z
<TaskGroupú>)r   ÚappendÚlenr   r   r	   Újoin)r   ÚinfoÚinfo_strs      r   Ú__repr__zTaskGroup.__repr__(   s“   € ØˆtˆØ�;Š;Ø�K‰K˜&¤ T§[¡[Ó!1Ð 2Ð3Ô4Ø�<Š<Ø�K‰K˜'¤# d§l¡lÓ"3Ð!4Ð5Ô6Ø�>Š>Ø�K‰K˜Õ%Ø�]Š]Ø�K‰K˜	Ô"à—8‘8˜D“>ˆØ˜H˜: QÐ'Ð'r   c              ƒ   ó  K  — | j                   rt        d| ›d�«      ‚| j                  €t        j                  «       | _        t        j                  | j                  «      | _        | j                  €t        d| ›d�«      ‚d| _         | S ­w)Nú
TaskGroup z has already been enteredz! cannot determine the parent taskT)r	   ÚRuntimeErrorr   r   Úget_running_loopr   Úcurrent_taskr   r   s    r   Ú
__aenter__zTaskGroup.__aenter__6   sŽ   è ø€ Ø�=Š=ÜØ˜T˜HÐ$=Ð>ó@ð @à�:‰:ÐÜ×0Ñ0Ó2ˆDŒJÜ!×.Ñ.¨t¯z©zÓ:ˆÔØ×ÑÐ$ÜØ˜T˜HÐ$EÐFóHð HàˆŒàˆùs   ‚B	Bc              ƒ   ó’  K  — d| _         |�$| j                  |«      r| j                  €|| _        |t        j                  u r|nd }| j
                  r| j                  j                  «       dk(  rd }|�| j                  s| j                  «        | j                  rT| j                  €| j                  j                  «       | _        	 | j                  ƒ d {  –—†  d | _        | j                  rŒT| j                  rJ ‚| j                  �| j                  ‚|r| j                  s|‚|�-|t        j                  ur| j                  j                  |«       | j                  r	 t!        d| j                  «      }|d ‚y 7 Œ¤# t        j                  $ r(}| j                  s|}| j                  «        Y d }~ŒØd }~ww xY w# d | _        w xY w­w)NTé    zunhandled errors in a TaskGroup)r
   Ú_is_base_errorr   r   ÚCancelledErrorr   r   Úuncancelr   Ú_abortr   r   r   Úcreate_futurer   r   ÚBaseExceptionGroup)r   ÚetÚexcÚtbÚpropagate_cancellation_errorÚexÚmes          r   Ú	__aexit__zTaskGroup.__aexit__D   s   è ø€ ØˆŒàˆOØ×#Ñ# CÔ(Ø× Ñ Ð(Ø"ˆDÔð œ×2Ñ2Ñ2‰C¸ð 	%à×(Ò(à× Ñ ×)Ñ)Ó+¨qÒ0ð 04Ð,àˆ>Ø—>’>ð —‘”ð �kŠkØ×%Ñ%Ð-Ø)-¯©×)AÑ)AÓ)C�Ô&ð"Ø×,Ñ,×,Ð,ð &*ˆDÔ"ð' �k‹kð* —;’;Ðˆà×ÑÐ'Ø×"Ñ"Ð"ñ (°·²Ø.Ð.àˆ>˜b¬
×(AÑ(AÑAØ�L‰L×Ñ Ô$à�<Š<ð$Ü'Ð(IÈ4Ï<É<ÓX�Ø˜dÐ"ð ð; -ùÜ×,Ñ,ò "Ø—~’~ð 46Ð0Ø—K‘K”Mÿøð"ûðH  $�•üsa   ‚CGÃE= ÃE;ÃE= ÃGÃ/A1GÅ!F; Å:GÅ;E= Å=F8ÆF3Æ.GÆ3F8Æ8GÆ;	GÇGN)ÚnameÚcontextc                ó  — | j                   st        d| ›d�«      ‚| j                  r| j                  st        d| ›d�«      ‚| j                  rt        d| ›d�«      ‚|€| j
                  j                  |«      }n| j
                  j                  ||¬«      }t        j                  ||«       |j                  «       r| j                  |«       |S | j                  j                  |«       |j                  | j                  «       |S )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
   r   r   r   Úcreate_taskr   Ú_set_task_nameÚdoneÚ_on_task_doneÚaddÚadd_done_callback)r   Úcoror:   r;   Útasks        r   r=   zTaskGroup.create_task•   sê   € ð
 �}Š}Ü ¨D¨8Ð3HÐIÓJÐJØ�=Š= §¢Ü ¨D¨8°<Ð@ÓAÐAØ�>Š>Ü ¨D¨8Ð3DÐEÓFÐFØˆ?Ø—:‘:×)Ñ)¨$Ó/‰Dà—:‘:×)Ñ)¨$¸Ð)Ó@ˆDÜ×Ñ˜T 4Ô(ð �9‰9Œ;Ø×Ñ˜tÔ$ð ˆð �K‰K�O‰O˜DÔ!Ø×"Ñ" 4×#5Ñ#5Ô6Øˆr   r4   Úreturnc                 óR   — t        |t        «      sJ ‚t        |t        t        f«      S )N)Ú
isinstanceÚBaseExceptionÚ
SystemExitÚKeyboardInterrupt)r   r4   s     r   r-   zTaskGroup._is_base_error³   s%   € Ü˜#œ}Ô-Ð-Ð-Ü˜#¤
Ô,=Ð>Ó?Ð?r   c                 óv   — d| _         | j                  D ]#  }|j                  «       rŒ|j                  «        Œ% y )NT)r   r   r?   Úcancel)r   Úts     r   r0   zTaskGroup._abort·   s.   € ØˆŒà—‘ò 	ˆAØ—6‘6•8Ø—‘•
ñ	r   c                 óÆ  — | j                   j                  |«       | j                  �A| j                   s5| j                  j                  «       s| j                  j	                  d«       |j                  «       ry |j                  «       }|€y | j                  j                  |«       | j                  |«      r| j                  €|| _
        | j                  j                  «       r1| j                  j                  d|›d| j                  › d�||dœ«       y | j                  s?| j                  s2| j!                  «        d| _        | j                  j#                  «        y y y )NTzTask z% has errored out but its parent task z is already completed)ÚmessageÚ	exceptionrD   )r   Údiscardr   r?   Ú
set_resultÚ	cancelledrP   r   r   r-   r   r   r   Úcall_exception_handlerr   r   r0   rL   )r   rD   r4   s      r   r@   zTaskGroup._on_task_done¾   s3  € Ø�‰×Ñ˜DÔ!à×!Ñ!Ð-°d·k²kØ×)Ñ)×.Ñ.Ô0Ø×&Ñ&×1Ñ1°$Ô7à�>‰>ÔØà�n‰nÓˆØˆ;Øà�‰×Ñ˜CÔ Ø×Ñ˜sÔ#¨×(8Ñ(8Ð(@Ø"ˆDÔà×Ñ×!Ñ!Ô#ð �J‰J×-Ñ-Ø" 4 (ð +#Ø#'×#4Ñ#4Ð"5Ð5JðLà Øñ	/ô ð à�~Š~ d×&CÒ&Cð& �K‰KŒMØ,0ˆDÔ)Ø×Ñ×$Ñ$Õ&ð+ 'Dˆ~r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r$   r*   r9   r=   rH   Úboolr-   r0   r@   © r   r   r   r      sI   „ ñò
&ò(òòO$ðb )-°dô ð<@ -ð @°Dó @òó2'r   r   N)Ú__all__r   r   r   r   r   rZ   r   r   ú<module>r\      s!   ðð
 €å Ý Ý ÷d'ò d'r   