XjddlmZddlZddlmZmZddlmZmZddl m Z ddl m Z ddl mZmZmZmZmZmZej(dk\rdd l mZndd lmZej(d k\r dd l mZmZndd lmZmZerd d lmZmZeddZedddZedZdddZ ddZ GddeeZ!GddeZ"y)) annotationsN)ABCMetaabstractmethod)Callable Coroutine)Context) TracebackType) TYPE_CHECKINGAnyLiteralProtocolfinaloverload) )TypeVar)r ) TypeVarTupleUnpack) CancelScope TaskHandleT_coT) covariantT_contra) contravariantdefaultPosArgsTc| t|St|dd}t|dd}dj||fDcgc]}|s| c}Scc}w)N __module__ __qualname__.)strgetattrjoin)funcoverridemodulequalnamexs d/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/anyio/abc/_tasks.pyget_callable_namer,sR8} T< .Ft^T2H 88 281aQ8 998s A A c ||i|}t|ts;t|dr|jdnd}t d||j d|d|S)z Call the given function with the given positional and keyword arguments. :return: the resulting coroutine :raises TypeError: if the return value was not a coroutine object r r"z Expected z0() to return a coroutine, but the return value (z) is not a coroutine object) isinstancerhasattrr TypeErrorr!)r&argskwargscoroprefixs r+call_for_coroutiner6%sr   D dI &*1$ *EDOO$A&2x 1 123!!%(C E  Kc:eZdZeddZeddZdddZy) TaskStatuscyNselfs r+startedzTaskStatus.started=s14r7cyr;r<r>values r+r?zTaskStatus.started@s03r7Ncy)zx Signal that the task has started. :param value: object passed back to the starter of the task Nr<rAs r+r?zTaskStatus.startedCr7)r>zTaskStatus[None]returnNone)rBrrErFr;)rBzT_contra | NonerErF)__name__r r!rr?r<r7r+r9r9<s# 44 33 r7r9c*eZdZUdZded<dddZeddd ddZedd dd Z e dd d  dd Z e dd dd Z eddd  ddZ eddZ e ddZ y) TaskGroupa Groups several asynchronous tasks together. :ivar cancel_scope: the cancel scope inherited by all child tasks :vartype cancel_scope: CancelScope .. note:: On asyncio, support for eager task factories is considered to be **experimental**. In particular, they don't follow the usual semantics of new tasks being scheduled on the next iteration of the event loop, and may thus cause unexpected behavior in code that wasn't written with such semantics in mind. r cancel_scopeNc:|jj|y)a  Cancel this task group's cancel scope immediately. This is a shortcut for calling ``.cancel_scope.cancel()`` on the task group. :param reason: a message describing the reason for the cancellation .. versionadded:: 4.14.0 N)rJcancel)r>reasons r+rLzTaskGroup.cancel[s   (r7)namecontextcy)a- Create a new task from a coroutine object and schedule it to run. :param coro: a coroutine object :param name: optional name to give the task :param context: optional context to run the task in :return: a task handle .. versionadded:: 4.14.0 Nr<)r>r4rNrOs r+ create_taskzTaskGroup.create_taskhrDr7rNcTt||}|jt|||S)a Start a new task in this task group. :param func: a coroutine function :param args: positional arguments to call the function with :param name: name of the task, for the purposes of introspection and debugging :return: a task handle .. versionadded:: 3.0 .. versionchanged:: 4.14.0 This method now returns a task handle. rR)r,rQr6)r>r&rNr2 final_names r+ start_soonzTaskGroup.start_soon{s.('tT2  24 >ZPPr7.)rN return_handlec Kywr;r<r>r&rNrVr2s r+startzTaskGroup.starts c Kywr;r<rXs r+rYzTaskGroup.starts !$rZFc Kyw)av Start a new task and wait until it signals for readiness. The target callable must accept a keyword argument ``task_status`` (of type :class:`TaskStatus`). Awaiting on this method will return whatever was passed to ``task_status.started()`` (``None`` by default). .. note:: The :class:`TaskStatus` class is generic, and the type argument should indicate the type of the value that will be passed to ``task_status.started()``. :param func: a coroutine function that accepts the ``task_status`` keyword argument :param args: positional arguments to call the function with :param name: an optional name for the task, for introspection and debugging :param return_handle: if ``True``, return a :class:`TaskHandle` which also contains the start value in ``start_value`` :return: the value passed to ``task_status.started()`` :raises RuntimeError: if the task finishes without calling ``task_status.started()`` .. seealso:: :ref:`start_initialize` .. versionadded:: 3.0 Nr<rXs r+rYzTaskGroup.startrZc Kyw)z:Enter the task group context and allow starting new tasks.Nr<r=s r+ __aenter__zTaskGroup.__aenter__r]rZc Kyw)zexc_typeexc_valexc_tbs r+ __aexit__zTaskGroup.__aexit__r]rZr;)rMz str | NonerErF)r4Coroutine[Any, Any, T_co]rNobjectrOzContext | NonerETaskHandle[T_co])r&7Callable[[Unpack[PosArgsT]], Coroutine[Any, Any, T_co]]r2zUnpack[PosArgsT]rNrfrErg) r&(Callable[..., Coroutine[Any, Any, T_co]]r2rfrNrfrVzLiteral[False]rEr ) r&rir2rfrNrfrVz Literal[True]rEzTaskHandle[T_co, Any]) r&rir2rfrNrfrVzLiteral[False] | Literal[True]rEr )rErI)raztype[BaseException] | NonerbzBaseException | NonerczTracebackType | NonerEbool)rGr r!__doc____annotations__rLrrQrrUrrYr_rdr<r7r+rIrIKs  ) "&  '        $  QEQ Q Q  Q Q, (+ 6  &    $6$$ $ % $  $$ 8=  6    6    BIIK,K&K% K  KKr7rI) metaclassr;)r&rr'rfrEr#)r&rhr2ztuple[Unpack[PosArgsT]]r3r rEre)# __future__rsysabcrrcollections.abcrr contextvarsrtypesr typingr r r r rr version_infortyping_extensionsrr _core._tasksrrrrrr,r6r9rIr<r7r+rxs" '/IIw)w++66v& :T4 @  #: A ! .  (#  FK'FKr7