a cG@s6UddlZddlZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z ddlmZejdkrrddlmZn ddlmZe d Ze d Zdd d d Zdd ddZdd ddZed ddZe ZiZeedfed<eddGdddZGdddejZGdddeeZ GdddeeZ!dS)N) dataclass)AnyDictGenericSetTypeVarUnionoverload)WeakKeyDictionary) get_asynclib))LiteralTDreturncstIdHdS)z Check for cancellation and allow the scheduler to switch to another task. Equivalent to (but more efficient than):: await checkpoint_if_cancelled() await cancel_shielded_checkpoint() .. versionadded:: 3.0 N)r checkpointrr[/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/anyio/lowlevel.pyrs rcstIdHdS)z Enter a checkpoint if the enclosing cancel scope has been cancelled. This does not allow the scheduler to switch to a different task. .. versionadded:: 3.0 N)r checkpoint_if_cancelledrrrrr!s rcstIdHdS)z Allow the scheduler to switch to another task but without checking for cancellation. Equivalent to (but potentially more efficient than):: with CancelScope(shield=True): await checkpoint() .. versionadded:: 3.0 N)r cancel_shielded_checkpointrrrrr-s rcCs tS)zVReturn a backend specific token object that can be used to get back to the event loop.)r current_tokenrrrrr<sr _TokenWrapper_token_wrappersT)frozenc@seZdZUdZeed<dS)r)_token __weakref__rN)__name__ __module__ __qualname__ __slots__object__annotations__rrrrrEs c@seZdZeZdS) _NoValueSetN)rr r!enumauto NO_VALUE_SETrrrrr%Ksr%c@s.eZdZdZdeeeejfdddZ dS) RunvarToken_var_value _redeemedz RunVar[T])varvaluecCs||_||_d|_dS)NFr*)selfr.r/rrr__init__RszRunvarToken.__init__N) rr r!r"rrrr%r(r1rrrrr)Osr)c@seZdZUdZdZejZeejed<e Z e e ed<efe eeeejfdddZeee efdd d Zeeeeefd d d Zeeddd Zefeeeejfeeefd dd ZeeedddZ eeddddZe dddZdS)RunVarzQLike a :class:`~contextvars.ContextVar`, expect scoped to the running event loop._name_defaultr(r)namedefaultcCs||_||_dSNr3)r0r6r7rrrr1cszRunVar.__init__rcCs^t}z t|WSty6t|}|j|YqtyVi}t|<|YS0qdSr8)r _run_vars TypeErrorrraddKeyError)r0tokenZrun_varsrrr _current_varsks    zRunVar._current_vars)r7rcCsdSr8rr0r7rrrget{sz RunVar.getcCsdSr8rr0rrrr@scCs`z|j|jWStyH|tjur.|YS|jtjurD|jYSYn0td|jddS)NzRun variable "z!" has no value and no default set)r>r4r<r2r(r5 LookupErrorr?rrrr@s    )r/rcCs*|j}t|||jtj}|||j<|Sr8)r>r)r@r4r2r()r0r/Z current_varsr=rrrsets z RunVar.setN)r=rcCsh|j|urtd|jr td|jtjurPz|j|j=Wq^tyLYq^0n|j|j|j<d|_dS)Nz)This token does not belong to this RunVarz This token has already been usedT) r+ ValueErrorr-r,r%r(r>r4r<)r0r=rrrresets   z RunVar.resetcCsd|jdS)Nz )r4rArrr__repr__szRunVar.__repr__)rr r!__doc__r"r%r(rr$rCrrrstrrrr1propertyrr>r rr@r)rErGrrrrr2Zs.   r2)"r&sysZ dataclassesrtypingrrrrrrr weakrefr Z_core._eventloopr version_inforZtyping_extensionsrrrrrr#rr9rr$rEnumr%r)r2rrrrs*  $