o
    i6                    @  sP!  U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZ ddlmZ ddlmZ ddlmZmZmZ ddlmZmZmZmZ dd	lmZ dd
lmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddl3Z3ddl4Z3ddl3m5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=Z>ddl?Z>ddl@Z>ddlAZ>ddlBZ>ddlCZ>ddlDZ>ddlEZ>ddlFmGZG ddlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z] e2d7ddZ^e2ddg e>j_j`jadd8d!dZ^e2dd"e>j_j`jad#d9d%dZ^	d:ddd"g e>j_j`jad&d;d(dZ^d<d+d,Zbd=d/d0ZcG d1d2 d2eZdG d3d4 d4eeZfG d5d6 d6eeZge2d>d8d9Zhe2edjidd:d?d>d9Zhe2edjidd:d@d@d9Zhe2edjidd:dAdBd9Zh	d:dd"edjiddCdBdFd9Zhe2dCdGdHZje2ddIdDdKdHZje2ddIdEdLdHZje2dFdMdHZj	d:dd"ddNdGdPdHZjeddQG dRdS dSZkdHdUdVZleddQG dWdX dXZmeddQG dYdZ dZZneddQG d[d\ d\ZoeddQG d]d^ d^ZpG d_d` d`eZqerdaZsdbetdc< dIdfdgZudJdidjZvdKdldmZwdLdodpZxdMdqddZydNdsdtZzdOdudvZ{dPdxdyZ|dQd|d}Z}e2e>j_j~fdRddZe2dSddZe2dTddZe>j_j~fdddUddZdVddZdWddZdOddZe2dXddZe2dYddZd:dZddZd[ddZd\ddZd]ddZd^ddZd_ddZd`ddZdaddZdbddZdcddZddddZe<G dd de:eYe[f Ze2deddZe2dfddZe2edjidd:dgddZe2edjidd:dhddZe2edjidd:diddZ	d:dd"edjiddCdjddZ	d:dkddȄZdldd˄Zdd̜dmddфZdddҜdndd؄Ze Ze Ze Ze ZG ddڄ deZG dd܄ d܃ZG ddބ dejZeeedZ	 eddQG dd dZdoddZdpddZdqddZeddQG dd dZeddQG dd dZeddQG ddń dŃZerG dd dejeI ZnG dd de$eI ejZG dd dee\ ZG dd deZG dd de;d"dZe2ddddddejddde>j_jjddrddZe2ddddddejddde>j_jjddsddZe2ddddddejddde>j_jjddtddZe2ddddddejddde>j_jjdduddZe2ddddddejddde>j_jjddvddZe2ddddddejddde>j_jjddwddZe2e>j_j~fg dddddddejddde>j_jjddxd#dZe>j_j~fg dddddddejddde>j_jjddyd$dZe2ddddddejddde>j_jjddzd&d'Ze2ddddddejddde>j_jjdd{d(d'Ze2ddddddejddde>j_jjdd|d)d'Ze2ddddddejddde>j_jjdd}d*d'Ze2ddddddejddde>j_jjdd~d+d'Ze2ddddddejddde>j_jjddd,d'Ze2e>j_j~fg dddddddejddde>j_jjddd-d'Ze>j_j~fg dddddddejddde>j_jjddd.d'Ze2ddddddejddde>j_jjddd0d1Ze2ddddddejddde>j_jjddd3d1Ze2ddddddejddde>j_jjddd5d1Ze2ddddddejddde>j_jjddd7d1Ze2ddddddejddde>j_jjddd9d1Ze2ddddddejddde>j_jjddd;d1Ze>j_j~fg ddddddejddde>j_jjd<dd>d1Ze2ddddddejddde>j_jjddd?d@Ze2ddddddejddde>j_jjdddAd@Ze2ddddddejddde>j_jjdddBd@Ze2ddddddejddde>j_jjdddCd@Ze2ddddddejddde>j_jjdddDd@Ze2ddddddejddde>j_jjdddEd@Ze>j_j~fg ddddddejddde>j_jjd<ddFd@Ze2ddddddejddde>j_jjdddHdIZe2ddddddejddde>j_jjdddKdIZe2ddddddejddde>j_jjdddMdIZe2ddddddejddde>j_jjdddOdIZe2ddddddejddde>j_jjdddQdIZe2ddddddejddde>j_jjdddSdIZe>j_j~fg ddddddejddde>j_jjd<ddTdIZe2ddddddejddde>j_jjdddUdVZe2ddddddejddde>j_jjdddWdVZe2ddddddejddde>j_jjdddXdVZe2ddddddejddde>j_jjdddYdVZe2ddddddejddde>j_jjdddZdVZe2ddddddejddde>j_jjddd[dVZe>j_j~fg ddddddejddde>j_jjd<dd\dVZG d]d^ d^e;d"dZe2dddddejddd_ddadbZe2ddddddejddcddddbZe2dddddejddd_ddedbZe2dddddejddd_ddfdbZe2dddddejddd_ddgdbZe2dddddejddd_ddhdbZe2e>j_j~fg ddddddejdddi
ddjdbZe>j_j~fg ddddddejdddi
ddkdbZe2dddddejddd_ddldmZe2dddddejddd_ddndmZe2dddddejddd_ddodmZe2dddddejddd_ddpdmZe2dddddejddd_ddqdmZe2dddddejddd_ddrdmZe2e>j_j~fg ddddddejdddi
ddsdmZe>j_j~fg ddddddejdddi
ddtdmZe2dddddejdduddvdwZe2dddddejdduddxdwZe2dddddejdduddydwZe2dddddejdduddzdwZe2dddddejddudd{dwZe2dddddejddudd|dwZe>j_j~fg dddddejddd}	dd~dwZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe>j_j~fg dddddejddd}	dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe2dddddejddd_dddZe>j_j~fg dddddejddd}	dddZe2dddddejddd_dÐddZe2dddddejddd_dĐddZe2dddddejddd_dŐddZe2dddddejddd_dƐddZe2dddddejddd_dǐddZe2dddddejddd_dȐddZe>j_j~fg dddddejddd}	dɐddZG dd dee\ e$e]e\f ZG dd deZG dd deZG dd de;d"dZe2ddejejddde>j_jjddddddde>j_jjddʐddZe2ddejejddde>j_jjddddddde>j_jjddːddZe2ddejejddde>j_jjddddddde>j_jjdd̐ddZe2e>j_j~fg dddejejddde>j_jjddddddde>j_jjdd͐ddZe>j_j~fg dddejejddde>j_jjddddddde>j_jjddΐddZe2ddejejddde>j_jjddddddde>j_jjddϐddZe2ddejejddde>j_jjddddddde>j_jjddАddZe2ddejejddde>j_jjddddddde>j_jjddѐddZe2e>j_j~fg dddejejddde>j_jjddddddde>j_jjddҐddZe>j_j~fg dddejejddde>j_jjddddddde>j_jjddӐddZG dd de$e6 ZG dd de$e] ZdddԐdŐdƄZdddՐdɐdʄZG dːd̄ deȃZe2e>j_j~fg dddddddd͜d֐dϐdЄZe2ddddddddќdאdӐdЄZe2ddddddddќdؐdՐdЄZe2ddddddddќdِdאdЄZe2g dddddddd͜dڐdؐdЄZe>j_j~fg dddddddddٜ	dېdېdЄZʐdܐdݐdބZːdݐddZ̐dސddZ͐dߐddZΐdܐddZϐdݐddZАdސddZѐdߐddZҐdܐddZdddddZԐdސddZdddddZ֐dOddZddddd Zere/deje dZn	e/dejِdZe2dejېddddZe2dejېddddZdejېddddZܐdddZݐdddZސdddZG dd de>jjZG dd de>jjZG d d! d!e>jjZG d"d# d#e>jjZG d$d% d%eZe/d&ZG d'd( d(eZG d)d* d*ee$e ZG d+d, d,ee Ze2dd1d2Ze2dd4d2Zdd6d2ZdS (  z:Utilities that can decorate or be called inside workflows.    )annotationsN)ABCabstractmethod)contextmanager)	dataclass)datetime	timedeltatimezone)EnumFlagIntEnumauto)partial)Random)TYPE_CHECKINGAny	AwaitableCallableDict	GeneratorGenericIterableIteratorListMappingMutableMappingNoReturnOptionalSequenceTupleTypeTypeVarUnioncastoverload)InputTOutputT)ConcatenateLiteralProtocol	TypedDictruntime_checkable)ServiceHandlerT   )AnyTypeCallableAsyncNoParamCallableAsyncSingleParamCallableAsyncTypeCallableSyncNoParam!CallableSyncOrAsyncReturnNoneTypeCallableSyncOrAsyncTypeCallableSyncSingleParamCallableType	ClassTypeMethodAsyncNoParamMethodAsyncSingleParamMethodSyncNoParamMethodSyncOrAsyncNoParamMethodSyncOrAsyncSingleParamMethodSyncSingleParamMultiParamSpec	ParamTypeProtocolReturnType
ReturnTypeSelfTypeclsr7   returnc                 C     d S N rC   rG   rG   Y/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/temporalio/workflow.pydefnY      rJ   Tname	sandboxedfailure_exception_typesversioning_behaviorrM   Optional[str]rN   boolrO   Sequence[Type[BaseException]]rP   $temporalio.common.VersioningBehavior Callable[[ClassType], ClassType]c                 C  rE   rF   rG   rL   rG   rG   rI   rJ   ]      FrN   dynamicrP   rX   c                 C  rE   rF   rG   rW   rG   rG   rI   rJ   g      )rM   rN   rX   rO   rP   Optional[ClassType]c                  s*   d fdd}| dur|| S |S )a  Decorator for workflow classes.

    This must be set on any registered workflow class (it is ignored if on a
    base class).

    Args:
        cls: The class to decorate.
        name: Name to use for the workflow. Defaults to class ``__name__``. This
            cannot be set if dynamic is set.
        sandboxed: Whether the workflow should run in a sandbox. Default is
            true.
        dynamic: If true, this activity will be dynamic. Dynamic workflows have
            to accept a single 'Sequence[RawValue]' parameter. This cannot be
            set to true if name is present.
        failure_exception_types: The types of exceptions that, if a
            workflow-thrown exception extends, will cause the workflow/update to
            fail instead of suspending the workflow via task failure. These are
            applied in addition to ones set on the worker constructor. If
            ``Exception`` is set, it effectively will fail a workflow/update in
            all user exception cases. WARNING: This setting is experimental.
        versioning_behavior: Specifies the versioning behavior to use for this workflow.
            WARNING: This setting is experimental.
    rC   r7   rD   c                   s&   t j|  s
p	| jnd d | S )N)workflow_namerN   rO   rP   )_Definition_apply_to_class__name__rH   rX   rO   rM   rN   rP   rG   rI   	decorator   s    zdefn.<locals>.decoratorNrC   r7   rD   r7   rG   )rC   rM   rN   rX   rO   rP   r`   rG   r_   rI   rJ   p   s   !init_fnr6   c                 C  s"   | j dkr	tdt| dd | S )aq  Decorator for the workflow init method.

    This may be used on the __init__ method of the workflow class to specify
    that it accepts the same workflow input arguments as the ``@workflow.run``
    method. If used, the parameters of your  __init__ and ``@workflow.run``
    methods must be identical.

    Args:
        init_fn: The __init__ method to decorate.
    __init__z6@workflow.init may only be used on the __init__ method__temporal_workflow_initT)r^   
ValueErrorsetattr)rb   rG   rG   rI   init   s   
rg   fnr1   c                 C  s4   t | s	tdd| jv rtdt| dd | S )a  Decorator for the workflow run method.

    This must be used on one and only one async method defined on the same class
    as ``@workflow.defn``. This can be defined on a base class method but must
    then be explicitly overridden and defined on the workflow class.

    Run methods can only have positional parameters. Best practice is to only
    take a single object/dataclass argument that can accept more fields later if
    needed.

    Args:
        fn: The function to decorate.
    z-Workflow run method must be an async functionz<locals>zCLocal classes unsupported, @workflow.run cannot be on a local class__temporal_workflow_runT)inspectiscoroutinefunctionre   __qualname__rf   rh   rG   rG   rI   run   s   

rn   c                   @  s   e Zd ZdZdZ	 dZdS )HandlerUnfinishedPolicya
  Actions taken if a workflow terminates with running handlers.

    Policy defining actions taken when a workflow exits while update or signal handlers are running.
    The workflow exit may be due to successful return, failure, cancellation, or continue-as-new.
    r-      N)r^   
__module__rl   __doc__WARN_AND_ABANDONABANDONrG   rG   rG   rI   ro      s    ro   c                   @     e Zd ZdZdS )UnfinishedUpdateHandlersWarningzFThe workflow exited before all update handlers had finished executing.Nr^   rq   rl   rr   rG   rG   rG   rI   rv          rv   c                   @  ru   )UnfinishedSignalHandlersWarningzFThe workflow exited before all signal handlers had finished executing.Nrw   rG   rG   rG   rI   ry      rx   ry   r3   c                 C  rE   rF   rG   rm   rG   rG   rI   signal      rz   unfinished_policydescriptionr}   r~   PCallable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType]c                 C  rE   rF   rG   r|   rG   rG   rI   rz      rV   strc                 C  rE   rF   rG   rM   r}   r~   rG   rG   rI   rz         Literal[True]c                 C  rE   rF   rG   rX   r}   r~   rG   rG   rI   rz     r   )rM   rX   r}   r~   +Optional[CallableSyncOrAsyncReturnNoneType]Optional[bool]c                  B   d fdd	}| s|d
urrt dt|||S || j|| S )aT  Decorator for a workflow signal method.

    This is used on any async or non-async method that you wish to be called upon
    receiving a signal. If a function overrides one with this decorator, it too
    must be decorated.

    Signal methods can only have positional parameters. Best practice for
    non-dynamic signal methods is to only take a single object/dataclass
    argument that can accept more fields later if needed. Return values from
    signal methods are ignored.

    Args:
        fn: The function to decorate.
        name: Signal name. Defaults to method ``__name__``. Cannot be present
            when ``dynamic`` is present.
        dynamic: If true, this handles all signals not otherwise handled. The
            parameters of the method must be self, a string name, and a
            ``*args`` positional varargs. Cannot be present when ``name`` is
            present.
        unfinished_policy: Actions taken if a workflow terminates with
            a running instance of this handler.
        description: A short description of the signal that may appear in the UI/CLI.
    rM   rQ   r}   ro   rh   r3   rD   c                   sF   | ss|j } t| |d| d}t|d| |jr!tjdtdd |S )NTrM   rh   	is_methodr}   r~   __temporal_signal_definitionzMDynamic signals with vararg third param is deprecated, use Sequence[RawValue]rp   
stacklevel)r^   _SignalDefinitionrf   dynamic_varargwarningswarnDeprecationWarningrM   r}   rh   rJ   r~   rX   rG   rI   r`   .  s"   zsignal.<locals>.decoratorN'Cannot provide name and dynamic boolean)rM   rQ   r}   ro   rh   r3   rD   r3   RuntimeErrorr   r^   rh   rM   rX   r}   r~   r`   rG   r   rI   rz     s    c                 C  rE   rF   rG   rm   rG   rG   rI   queryM  rK   r   r~   &Callable[[CallableType], CallableType]c                 C  rE   rF   rG   )rM   r~   rG   rG   rI   r   Q  r{   c                 C  rE   rF   rG   )rX   r~   rG   rG   rI   r   W  r{   c                 C  rE   rF   rG   r   rG   rG   rI   r   ]  rK   )rM   rX   r~   Optional[CallableType]c                  s   ddd fdd}|dus s|r"|dur rt dt|||S | du r*t dt| r7tjdtdd || j|| ddS )a7  Decorator for a workflow query method.

    This is used on any non-async method that expects to handle a query. If a
    function overrides one with this decorator, it too must be decorated.

    Query methods can only have positional parameters. Best practice for
    non-dynamic query methods is to only take a single object/dataclass
    argument that can accept more fields later if needed. The return value is
    the resulting query value. Query methods must not mutate any workflow state.

    Args:
        fn: The function to decorate.
        name: Query name. Defaults to method ``__name__``. Cannot be present
            when ``dynamic`` is present.
        dynamic: If true, this handles all queries not otherwise handled. The
            parameters of the method should be self, a string name, and a
            ``Sequence[RawValue]``. An older form of this accepted vararg
            parameters which will now warn. Cannot be present when ``name`` is
            present.
        description: A short description of the query that may appear in the UI/CLI.
    F)bypass_async_checkrM   rQ   r~   rh   r6   r   rR   rD   c                  sb   | s s|j } |st|rtjdtdd t| |d|d}t|d| |jr/tjdtdd |S )N-Queries as async def functions are deprecatedrp   r   T)rM   rh   r   r~   __temporal_query_definitionzMDynamic queries with vararg third param is deprecated, use Sequence[RawValue])	r^   rj   rk   r   r   r   _QueryDefinitionrf   r   )rM   r~   rh   r   rJ   rX   rG   rI   r`   ~  s&   zquery.<locals>.decoratorNr   z7Cannot create query without function or name or dynamicr   rp   r   T)
rM   rQ   r~   rQ   rh   r6   r   rR   rD   r6   )r   r   rj   rk   r   r   r   r^   )rh   rM   rX   r~   r`   rG   r   rI   r   a  s   "
)frozenc                   @  s2   e Zd ZU dZdZded< 	 ejjj	Z
ded< dS )DynamicWorkflowConfigzUReturned by functions using the :py:func:`dynamic_config` decorator, see it for more.Nz'Optional[Sequence[Type[BaseException]]]rO   rT   rP   )r^   rq   rl   rr   rO   __annotations__
temporaliocommonVersioningBehaviorUNSPECIFIEDrP   rG   rG   rG   rI   r     s   
 

r   2MethodSyncNoParam[SelfType, DynamicWorkflowConfig]c                 C  sJ   t | r	tdtt | j }t|dkrtdt| dd | S )a  Decorator to allow configuring a dynamic workflow's behavior.

    Because dynamic workflows may conceptually represent more than one workflow type, it may be
    desirable to have different settings for fields that would normally be passed to
    :py:func:`defn`, but vary based on the workflow type name or other information available in
    the workflow's context. This function will be called after the workflow's :py:func:`init`,
    if it has one, but before the workflow's :py:func:`run` method.

    The method must only take self as a parameter, and any values set in the class it returns will
    override those provided to :py:func:`defn`.

    Cannot be specified on non-dynamic workflows.

    Args:
        fn: The function to decorate.
    z2Workflow dynamic_config method must be synchronousr-   z<Workflow dynamic_config method must only take self parameter"__temporal_workflow_dynamic_configT)	rj   rk   re   list	signature
parametersvalueslenrf   )rh   paramsrG   rG   rI   dynamic_config  s   
r   c                   @  s  e Zd ZU dZded< ded< ded< ded< d	ed
< ded< d	ed< ded< ded< ded< 	 ded< ded< d	ed< ded< ded< 	 ded< 	 d	ed< ded< d ed!< 	 d	ed"< ded#< 	 d	ed$< d6d'd(Zd7d)d*Zd8d,d-Zd9d.d/Zd9d0d1Z	d:d3d4Z
d5S );Infoa  Information about the running workflow.

    Retrieved inside a workflow via :py:func:`info`. This object is immutable
    with the exception of the :py:attr:`search_attributes` and
    :py:attr:`typed_search_attributes` which is updated on
    :py:func:`upsert_search_attributes`.

    Note, required fields may be added here in future versions. This class
    should never be constructed by users.
    intattemptrQ   continued_run_idcron_scheduleOptional[timedelta]execution_timeoutr   first_execution_run_idz.Mapping[str, temporalio.api.common.v1.Payload]headers	namespacezOptional[ParentInfo]parentzOptional[RootInfo]roottemporalio.common.Prioritypriorityraw_memo'Optional[temporalio.common.RetryPolicy]retry_policyrun_idrun_timeoutz"temporalio.common.SearchAttributessearch_attributesr   
start_time
task_queuer   task_timeoutz'temporalio.common.TypedSearchAttributestyped_search_attributesworkflow_idworkflow_start_timeworkflow_typerD   Mapping[str, Any]c                 C  s   | j | j| j| j| j| jdS )Nr   r   r   r   r   r   r   selfrG   rG   rI   _logger_details  s   zInfo._logger_detailsc                 C     t   S )a  Get the Build ID of the worker which executed the current Workflow Task.

        May be undefined if the task was completed by a worker without a Build ID. If this worker is
        the one executing this task for the first time and has a Build ID set, then its ID will be
        used. This value may change over the lifetime of the workflow run, but is deterministic and
        safe to use for branching.

        .. deprecated::
            Use get_current_deployment_version instead.
        )_Runtimecurrentworkflow_get_current_build_idr   rG   rG   rI   get_current_build_id$     zInfo.get_current_build_id3Optional[temporalio.common.WorkerDeploymentVersion]c                 C  r   )a  Get the deployment version of the worker which executed the current Workflow Task.

        May be None if the task was completed by a worker without a deployment version or build
        id. If this worker is the one executing this task for the first time and has a deployment
        version set, then its ID will be used. This value may change over the lifetime of the
        workflow run, but is deterministic and safe to use for branching.
        )r   r   'workflow_get_current_deployment_versionr   rG   rG   rI   get_current_deployment_version1     
z#Info.get_current_deployment_versionc                 C  r   )zGet the current number of events in history.

        Note, this value may not be up to date if accessed inside a query.

        Returns:
            Current number of events in history (up until the current task).
        )r   r   #workflow_get_current_history_lengthr   rG   rG   rI   get_current_history_length=     zInfo.get_current_history_lengthc                 C  r   )zGet the current byte size of history.

        Note, this value may not be up to date if accessed inside a query.

        Returns:
            Current byte-size of history (up until the current task).
        )r   r   !workflow_get_current_history_sizer   rG   rG   rI   get_current_history_sizeG  r   zInfo.get_current_history_sizerR   c                 C  r   )a   Get whether or not continue as new is suggested.

        Note, this value may not be up to date if accessed inside a query.

        Returns:
            True if the server is configured to suggest continue as new and it
            is suggested.
        )r   r   %workflow_is_continue_as_new_suggestedr   rG   rG   rI   is_continue_as_new_suggestedQ     	z!Info.is_continue_as_new_suggestedNrD   r   rD   r   rD   r   rD   r   rD   rR   )r^   rq   rl   rr   r   r   r   r   r   r   r   rG   rG   rG   rI   r     sF   
 






r   c                   @  s*   e Zd ZU dZded< ded< ded< dS )
ParentInfoz&Information about the parent workflow.r   r   r   r   Nr^   rq   rl   rr   r   rG   rG   rG   rI   r   ]  s
   
 r   c                   @  s"   e Zd ZU dZded< ded< dS )RootInfoz$Information about the root workflow.r   r   r   Nr   rG   rG   rG   rI   r   f  s   
 r   c                   @  s4   e Zd ZU dZded< 	 ded< 	 ed
ddZd	S )
UpdateInfoz$Information about a workflow update.r   idrM   rD   r   c                 C  s   | j | jdS )zAData to be included in string appended to default logging output.)	update_idupdate_name)r   rM   r   rG   rG   rI   r   x  s   zUpdateInfo._logger_detailsNr   )r^   rq   rl   rr   r   propertyr   rG   rG   rG   rI   r   n  s   
 r   c                      s  e Zd ZedddZedddZedddZdÇ fddZedddZ	e
dddZe
dd'd(Ze
dd*d+Ze
dd-d.Ze
dd0d1Ze
dd3d4Ze
dd5d6Ze
dd:d;Ze
dd>d?Ze
dd@dAZe
ddBdCZe
ddDdEZe
ddGdHZe
ddIdJZe
ddKdLZe
ddMdNZe
ddOdPZe
ddUdVZe
ddXdYZe
dd[d\Ze
dd^d_Ze
ddadbZ e
ddddeZ!e
ddgdhZ"e
ddidjZ#e
ddldmZ$e
dne%j&j'j(dodd}d~Z)e
dndne%j&j'j(ddddZ*e
dddZ+e
dddZ,e
dddZ-e
dddZ.e
dnddddZ/e
dndnddddZ0e
dddZ1e
dddZ2e
dddZ3e
dddZ4e
dddZ5e
dddZ6  Z7S )r   rD   c                  C  s   t  } | s
td| S NzNot in workflow event loop)r   maybe_current_NotInWorkflowEventLoopErrorlooprG   rG   rI   r     s   z_Runtime.currentOptional[_Runtime]c                   C  s(   z	t t dd W S  ty   Y d S w N__temporal_workflow_runtime)getattrasyncioget_running_loopr   rG   rG   rG   rI   r     s   
z_Runtime.maybe_currentr   asyncio.AbstractEventLoopruntimeNonec                 C  s0   |r
t | d| d S t| drt| d d S d S r   )rf   hasattrdelattr)r   r   rG   rG   rI   set_on_loop  s
   
z_Runtime.set_on_loopc                   s   t    d | _d S rF   )superrc   r   r   	__class__rG   rI   rc     s   

z_Runtime.__init__r   c                 C  s   | j d u r|    | _ | j S rF   )r   workflow_infor   rG   rG   rI   logger_details  s   
z_Runtime.logger_detailsrR   c                 C  rE   rF   rG   r   rG   rG   rI   workflow_all_handlers_finished  rK   z'_Runtime.workflow_all_handlers_finishedargsr   workflowUnion[None, Callable, str]r   rQ   r   r   r   r   r   memoOptional[Mapping[str, Any]]r   \Optional[Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]]versioning_intentOptional[VersioningIntent]r   c          
      G  rE   rF   rG   )
r   r  r   r   r   r   r
  r   r  r  rG   rG   rI   workflow_continue_as_new     z!_Runtime.workflow_continue_as_newMapping[str, Callable]c                 C  rE   rF   rG   r   rG   rG   rI   workflow_extern_functions  rK   z"_Runtime.workflow_extern_functionsr   c                 C  rE   rF   rG   r   rG   rG   rI   r     rK   z&_Runtime.workflow_get_current_build_idr   c                 C  rE   rF   rG   r   rG   rG   rI   r     r{   z0_Runtime.workflow_get_current_deployment_versionr   c                 C  rE   rF   rG   r   rG   rG   rI   r     rK   z,_Runtime.workflow_get_current_history_lengthc                 C  rE   rF   rG   r   rG   rG   rI   r     rK   z*_Runtime.workflow_get_current_history_sizer   r   ExternalWorkflowHandle[Any]c                C  rE   rF   rG   )r   r   r   rG   rG   rI   %workflow_get_external_workflow_handle  r{   z._Runtime.workflow_get_external_workflow_handlerM   Optional[Callable]c                 C  rE   rF   rG   r   rM   rG   rG   rI   workflow_get_query_handler  rK   z#_Runtime.workflow_get_query_handlerc                 C  rE   rF   rG   r  rG   rG   rI   workflow_get_signal_handler  r{   z$_Runtime.workflow_get_signal_handlerc                 C  rE   rF   rG   r  rG   rG   rI   workflow_get_update_handler  r{   z$_Runtime.workflow_get_update_handlerc                 C  rE   rF   rG   r  rG   rG   rI   workflow_get_update_validator  r{   z&_Runtime.workflow_get_update_validatorr   c                 C  rE   rF   rG   r   rG   rG   rI   r    rK   z_Runtime.workflow_infoc                 C  rE   rF   rG   r   rG   rG   rI   workflow_instance  rK   z_Runtime.workflow_instancec                 C  rE   rF   rG   r   rG   rG   rI   r     rK   z._Runtime.workflow_is_continue_as_new_suggestedc                 C  rE   rF   rG   r   rG   rG   rI   workflow_is_replaying  rK   z_Runtime.workflow_is_replayingc                 C  rE   rF   rG   r   rG   rG   rI   workflow_memo  rK   z_Runtime.workflow_memokeydefault	type_hintOptional[Type]c                C  rE   rF   rG   )r   r  r  r   rG   rG   rI   workflow_memo_value  r{   z_Runtime.workflow_memo_valueupdatesc                 C  rE   rF   rG   )r   r#  rG   rG   rI   workflow_upsert_memo  rK   z_Runtime.workflow_upsert_memotemporalio.common.MetricMeterc                 C  rE   rF   rG   r   rG   rG   rI   workflow_metric_meter  rK   z_Runtime.workflow_metric_meter
deprecatedc                C  rE   rF   rG   )r   r   r'  rG   rG   rI   workflow_patch  rK   z_Runtime.workflow_patch%temporalio.converter.PayloadConverterc                 C  rE   rF   rG   r   rG   rG   rI   workflow_payload_converter   rK   z#_Runtime.workflow_payload_converterr   c                 C  rE   rF   rG   r   rG   rG   rI   workflow_random  rK   z_Runtime.workflow_randomhandlerc                 C  rE   rF   rG   r   rM   r,  rG   rG   rI   workflow_set_query_handler  r{   z#_Runtime.workflow_set_query_handlerc                 C  rE   rF   rG   r-  rG   rG   rI   workflow_set_signal_handler  r{   z$_Runtime.workflow_set_signal_handler	validatorc                 C  rE   rF   rG   )r   rM   r,  r0  rG   rG   rI   workflow_set_update_handler  rY   z$_Runtime.workflow_set_update_handlerN)summaryr   activityresult_typeschedule_to_close_timeoutschedule_to_start_timeoutstart_to_close_timeoutheartbeat_timeoutcancellation_typeActivityCancellationTypeactivity_idr2  r   r   ActivityHandle[Any]c                G  rE   rF   rG   )r   r3  r   r4  r5  r6  r7  r8  r   r9  r;  r  r2  r   r  rG   rG   rI   workflow_start_activity  r  z _Runtime.workflow_start_activity)static_summarystatic_detailsr   ChildWorkflowCancellationTypeparent_close_policyParentClosePolicyr   id_reuse_policy'temporalio.common.WorkflowIDReusePolicyr   r>  r?  ChildWorkflowHandle[Any, Any]c                     d S rF   rG   )r   r  r   r   r4  r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   r  rG   rG   rI   workflow_start_child_workflow+     z&_Runtime.workflow_start_child_workflowlocal_retry_thresholdc       	         G  rE   rF   rG   )r   r3  r4  r5  r6  r7  r   rI  r9  r;  r2  r  rG   rG   rI   workflow_start_local_activityH  s   z&_Runtime.workflow_start_local_activityendpointservice	operationCUnion[nexusrpc.Operation[InputT, OutputT], str, Callable[..., Any]]inputoutput_typeOptional[Type[OutputT]]2temporalio.workflow.NexusOperationCancellationTyper   Optional[Mapping[str, str]]NexusOperationHandle[OutputT]c	           	        rF  rF   rG   )	r   rK  rL  rM  rO  rP  r5  r9  r   rG   rG   rI   workflow_start_nexus_operationX     z'_Runtime.workflow_start_nexus_operationc                 C  rE   rF   rG   r   rG   rG   rI   workflow_time_nse  rK   z_Runtime.workflow_time_ns
attributes\Union[temporalio.common.SearchAttributes, Sequence[temporalio.common.SearchAttributeUpdate]]c                 C  rE   rF   rG   )r   rX  rG   rG   rI   !workflow_upsert_search_attributesh  rV   z*_Runtime.workflow_upsert_search_attributesr2  durationfloatc                  rF  rF   rG   )r   r\  r2  rG   rG   rI   workflow_sleepq  s   z_Runtime.workflow_sleeptimeouttimeout_summaryrh   Callable[[], bool]r`  Optional[float]ra  c                  rF  rF   rG   )r   rh   r`  ra  rG   rG   rI   workflow_wait_conditionv     z _Runtime.workflow_wait_conditionc                 C  rE   rF   rG   r   rG   rG   rI   workflow_get_current_details  rK   z%_Runtime.workflow_get_current_detailsdetailsc                 C  rE   rF   rG   )r   rg  rG   rG   rI   workflow_set_current_details  rK   z%_Runtime.workflow_set_current_detailserrBaseExceptionc                 C  rE   rF   rG   )r   ri  rG   rG   rI   workflow_is_failure_exception  rK   z&_Runtime.workflow_is_failure_exceptionc                 C  rE   rF   rG   r   rG   rG   rI   #workflow_has_last_completion_result  rK   z,_Runtime.workflow_has_last_completion_resultOptional[Any]c                 C  rE   rF   rG   )r   r   rG   rG   rI   workflow_last_completion_result  r{   z(_Runtime.workflow_last_completion_resultOptional[BaseException]c                 C  rE   rF   rG   r   rG   rG   rI   workflow_last_failure  rK   z_Runtime.workflow_last_failure)rD   r   )rD   r   )r   r   r   r   rD   r   rD   r   r   r   )r  r   r  r	  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   rD   r  r   r   r   )r   r   r   rQ   rD   r  )rM   rQ   rD   r  rD   r   rD   r   r  r   r  r   r   r!  rD   r   r#  r   rD   r   rD   r%  )r   r   r'  rR   rD   rR   rD   r)  rD   r   )rM   rQ   r,  r  rD   r   )rM   rQ   r,  r  r0  r  rD   r   )r3  r   r  r   r   rQ   r4  r!  r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r<  )(r  r   r  r   r   r   r   rQ   r4  r!  r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   rE  )r3  r   r  r   r4  r!  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r<  )rK  r   rL  r   rM  rN  rO  r   rP  rQ  r5  r   r9  rR  r   rS  rD   rT  rX  rY  rD   r   )r\  r]  r2  rQ   rD   r   )rh   rb  r`  rc  ra  rQ   rD   r   )rg  r   ri  rj  rD   rR   r   r!  rD   rm  rD   ro  )8r^   rq   rl   staticmethodr   r   r   rc   r   r  r   r  r  r  r   r   r   r   r  r  r  r  r  r  r  r   r  r  r"  r$  r&  r(  r*  r+  r.  r/  r1  r   r   Priorityr  r=  rG  rJ  rU  rW  rZ  r^  rd  rf  rh  rk  rl  rn  rp  __classcell__rG   rG   r  rI   r     s    r   __temporal_current_update_infoz"contextvars.ContextVar[UpdateInfo]_current_update_infoinfor   c                 C  s   t |  d S rF   )r  set)r  rG   rG   rI   _set_current_update_info  s   r  Optional[UpdateInfo]c                   C  s
   t dS )a%  Info for the current update if any.

    This is powered by :py:mod:`contextvars` so it is only valid within the
    update handler and coroutines/tasks it has started.

    Returns:
        Info for the current update handler the code calling this is executing
            within if any.
    N)r  getrG   rG   rG   rI   current_update_info  s   

r  r   c                 C  s   t  j| dd dS )aw  Mark a patch as deprecated.

    This marks a workflow that had :py:func:`patched` in a previous version of
    the code as no longer applicable because all workflows that use the old code
    path are done and will never be queried again. Therefore the old code path
    is removed as well.

    Args:
        id: The identifier originally used with :py:func:`patched`.
    Tr'  Nr   r   r(  r   rG   rG   rI   deprecate_patch  s   r  r  c                   C  r   )zExternal functions available in the workflow sandbox.

    Returns:
        Mapping of external functions that can be called from inside a workflow
        sandbox.
    )r   r   r  rG   rG   rG   rI   extern_functions     r  c                   C  r   )z\Current workflow's info.

    Returns:
        Info for the currently running workflow.
    )r   r   r  rG   rG   rG   rI   r       r   c                   C  r   )z`Current workflow's instance.

    Returns:
        The currently running workflow instance.
    )r   r   r  rG   rG   rG   rI   instance  r  r  c                   C  s   t  duS )z4Whether the code is currently running in a workflow.N)r   r   rG   rG   rG   rI   in_workflow     r  r   c                   C  r   )a  Current workflow's memo values, converted without type hints.

    Since type hints are not used, the default converted values will come back.
    For example, if the memo was originally created with a dataclass, the value
    will be a dict. To convert using proper type hints, use
    :py:func:`memo_value`.

    Returns:
        Mapping of all memo keys and they values without type hints.
    )r   r   r  rG   rG   rG   rI   r
    r   r
  ri  rj  c                 C     t  | S )zChecks if the given exception is a workflow failure in the current workflow.

    Returns:
        True if the given exception is a workflow failure in the current workflow.
    )r   r   rk  )ri  rG   rG   rI   is_failure_exception  s   r  r  r  c                 C  rE   rF   rG   )r  r  rG   rG   rI   
memo_value  rK   r  r   Type[ParamType]r?   c                C  rE   rF   rG   )r  r   rG   rG   rI   r    rK   r.   Union[AnyType, ParamType]c                C  rE   rF   rG   r  r  r   rG   rG   rI   r    r{   r   r!  c                C  s   t  j| ||dS )a  Memo value for the given key, optional default, and optional type
    hint.

    Args:
        key: Key to get memo value for.
        default: Default to use if key is not present. If unset, a
            :py:class:`KeyError` is raised when the key does not exist.
        type_hint: Type hint to use when converting.

    Returns:
        Memo value, converted with the type hint if present.

    Raises:
        KeyError: Key not present and default not set.
    r  )r   r   r"  r  rG   rG   rI   r    s   r#  c                 C  r  )a  Adds, modifies, and/or removes memos, with upsert semantics.

    Every memo that has a matching key has its value replaced with the one specified in ``updates``.
    If the value is set to ``None``, the memo is removed instead.
    For every key with no existing memo, a new memo is added with specified value (unless the value is ``None``).
    Memos with keys not included in ``updates`` remain unchanged.
    )r   r   r$  )r#  rG   rG   rI   upsert_memo  s   r  c                   C  r   )a)  Get the current details of the workflow which may appear in the UI/CLI.
    Unlike static details set at start, this value can be updated throughout
    the life of the workflow and is independent of the static details.
    This can be in Temporal markdown format and can span multiple lines.
    )r   r   rf  rG   rG   rG   rI   get_current_details!  r  r  c                   C  r   )z?Gets whether there is a last completion result of the workflow.)r   r   rl  rG   rG   rG   rI   has_last_completion_result*  r  r  rm  c                   C  rE   rF   rG   rG   rG   rG   rI   get_last_completion_result/  rK   r  Optional[ParamType]c                 C  rE   rF   rG   r  rG   rG   rI   r  3  rK   c                 C  r  )zGet the result of the last run of the workflow. This will be None if there was
    no previous completion or the result was None. has_last_completion_result()
    can be used to differentiate.
    )r   r   rn  r  rG   rG   rI   r  7  s   ro  c                   C  r   )z>Get the last failure of the workflow if it has run previously.)r   r   rp  rG   rG   rG   rI   get_last_failure?  r  r  c                 C  s   t  |  dS )a)  Set the current details of the workflow which may appear in the UI/CLI.
    Unlike static details set at start, this value can be updated throughout
    the life of the workflow and is independent of the static details.
    This can be in Temporal markdown format and can span multiple lines.
    N)r   r   rh  r   rG   rG   rI   set_current_detailsD  s   r  r%  c                   C  r   )zGet the metric meter for the current workflow.

    This meter is replay safe which means that metrics will not be recorded
    during replay.

    Returns:
        Current metric meter for this workflow for recording metrics.
    )r   r   r&  rG   rG   rG   rI   metric_meterM  r   r  r   c                   C  s   t t tjS )a  Current time from the workflow perspective.

    This is the workflow equivalent of :py:func:`datetime.now` with the
    :py:attr:`timezone.utc` parameter.

    Returns:
        UTC datetime for the current workflow time. The datetime does have UTC
        set as the time zone.
    )r   fromtimestamptimer	   utcrG   rG   rG   rI   nowY  s   
r  c                 C  s   t  j| ddS )ae  Patch a workflow.

    When called, this will only return true if code should take the newer path
    which means this is either not replaying or is replaying and has seen this
    patch before.

    Use :py:func:`deprecate_patch` when all workflows are done and will never be
    queried again. The old code path can be used at that time too.

    Args:
        id: The identifier for this patch. This identifier may be used
            repeatedly in the same workflow to represent the same patch

    Returns:
        True if this should take the newer path, false if it should take the
        older path.
    Fr  r  r  rG   rG   rI   patchedf  s   r  r)  c                   C  r   )zGet the payload converter for the current workflow.

    The returned converter has :py:class:`temporalio.converter.WorkflowSerializationContext` set.
    This is often used for dynamic workflows/signals/queries to convert
    payloads.
    )r   r   r*  rG   rG   rG   rI   payload_converter{  r  r  r   c                   C  r   )a  Get a deterministic pseudo-random number generator.

    Note, this random number generator is not cryptographically safe and should
    not be used for security purposes.

    Returns:
        The deterministically-seeded pseudo-random number generator.
    )r   r   r+  rG   rG   rG   rI   random  r   r  r]  c                   C  s
   t  d S )zCurrent seconds since the epoch from the workflow perspective.

    This is the workflow equivalent of :py:func:`time.time`.

    Returns:
        Seconds since the epoch as a float.
    g    eA)time_nsrG   rG   rG   rI   r    s   
r  r   c                   C  r   )zCurrent nanoseconds since the epoch from the workflow perspective.

    This is the workflow equivalent of :py:func:`time.time_ns`.

    Returns:
        Nanoseconds since the epoch
    )r   r   rW  rG   rG   rG   rI   r    r   r  rX  rY  c                 C  s&   | sdS t j|  t |  dS )a  Upsert search attributes for this workflow.

    Args:
        attributes: The attributes to set. This should be a sequence of
            updates (i.e. values created via value_set and value_unset calls on
            search attribute keys). The dictionary form of attributes is
            DEPRECATED and if used, result in invalid key types on the
            typed_search_attributes property in the info.
    N)r   r   %_warn_on_deprecated_search_attributesr   r   rZ  )rX  rG   rG   rI   upsert_search_attributes  s   r  c                   @  s.   e Zd ZU dZded< dd
dZdddZdS )UpdateMethodMultiParamz3Decorated workflow update functions implement this.z%temporalio.workflow._UpdateDefinition_defnr  MultiParamSpec.argskwargsMultiParamSpec.kwargsrD   8Union[ProtocolReturnType, Awaitable[ProtocolReturnType]]c                 O     dS )zGeneric callable type callback.NrG   )r   r  r  rG   rG   rI   __call__     zUpdateMethodMultiParam.__call__vfuncCallable[MultiParamSpec, None]c                 C  r  )zRUse to decorate a function to validate the arguments passed to the update handler.NrG   )r   r  rG   rG   rI   r0    r  z UpdateMethodMultiParam.validatorN)r  r  r  r  rD   r  )r  r  rD   r  )r^   rq   rl   rr   r   r  r0  rG   rG   rG   rI   r    s
   
 
r  /Callable[MultiParamSpec, Awaitable[ReturnType]]2UpdateMethodMultiParam[MultiParamSpec, ReturnType]c                 C  rE   rF   rG   rm   rG   rG   rI   update  r{   r  $Callable[MultiParamSpec, ReturnType]c                 C  rE   rF   rG   rm   rG   rG   rI   r    r{   dCallable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType]]c                 C  rE   rF   rG   r|   rG   rG   rI   r    r   c                 C  rE   rF   rG   r   rG   rG   rI   r       	c                 C  rE   rF   rG   r   rG   rG   rI   r    r  !Optional[CallableSyncOrAsyncType]c                  r   )aj  Decorator for a workflow update handler method.

    This is used on any async or non-async method that you wish to be called upon
    receiving an update. If a function overrides one with this decorator, it too
    must be decorated.

    You may also optionally define a validator method that will be called before
    this handler you have applied this decorator to. You can specify the validator
    with ``@update_handler_function_name.validator``.

    Update methods can only have positional parameters. Best practice for
    non-dynamic update methods is to only take a single object/dataclass
    argument that can accept more fields later if needed. The handler may return
    a serializable value which will be sent back to the caller of the update.

    Args:
        fn: The function to decorate.
        name: Update name. Defaults to method ``__name__``. Cannot be present
            when ``dynamic`` is present.
        dynamic: If true, this handles all updates not otherwise handled. The
            parameters of the method must be self, a string name, and a
            ``*args`` positional varargs. Cannot be present when ``name`` is
            present.
        unfinished_policy: Actions taken if a workflow terminates with
            a running instance of this handler.
        description: A short description of the update that may appear in the UI/CLI.
    rM   rQ   r}   ro   rh   r4   rD   c                   sP   | ss|j } t| |d| d}|jrtdt|d| t|dtt| |S )NTr   KDynamic updates do not support a vararg third param, use Sequence[RawValue]r  r0  )r^   _UpdateDefinitionr   r   rf   r   _update_validatorr   r   rG   rI   r`   #  s    zupdate.<locals>.decoratorNr   )rM   rQ   r}   ro   rh   r4   rD   r4   r   r   rG   r   rI   r    s   $
update_defr  Optional[Callable[..., None]]c                 C  s   |dur	|  | |S )z1Decorator for a workflow update validator method.N)set_validator)r  rh   rG   rG   rI   r  A  s   
r  	uuid.UUIDc                   C  s   t jt dddddS )zGet a new, determinism-safe v4 UUID based on :py:func:`random`.

    Note, this UUID is not cryptographically safe and should not be used for
    security purposes.

    Returns:
        A deterministically-seeded v4 UUID.
          big   )bytesversion)uuidUUIDr  getrandbitsto_bytesrG   rG   rG   rI   uuid4J  s   	r  r[  r\  Union[float, timedelta]r2  c                  s0   t  jt| tr|  n| |dI dH  dS )a  Sleep for the given duration.

    Args:
        duration: Duration to sleep in seconds or as a timedelta.
        summary: A single-line fixed summary for this timer that may appear in UI/CLI.
            This can be in single-line Temporal markdown format.
    r\  r2  N)r   r   r^  
isinstancer   total_secondsr  rG   rG   rI   sleepV  s
   
r  r_  rb  r`  !Optional[Union[timedelta, float]]ra  c                  s2   t  j| t|tr| n||dI dH  dS )aR  Wait on a callback to become true.

    This function returns when the callback returns true (invoked each loop
    iteration) or the timeout has been reached.

    Args:
        fn: Non-async callback that accepts no parameters and returns a boolean.
        timeout: Optional number of seconds to wait until throwing
            :py:class:`asyncio.TimeoutError`.
        timeout_summary: Optional simple string identifying the timer (created if ``timeout`` is
            present) that may be visible in UI/CLI. While it can be normal text, it is best to treat
            as a timer ID.
    r_  N)r   r   rd  r  r   r  )rh   r`  ra  rG   rG   rI   wait_conditionh  s   r  c                   @  s.   e Zd ZdZe Z	 e Z	 e Z	 e ZdS )SandboxImportNotificationPolicyzDefines the behavior taken when modules are imported into the sandbox after the workflow is initially loaded or unintentionally missing from the passthrough list.N)	r^   rq   rl   rr   r   SILENTWARN_ON_DYNAMIC_IMPORT!WARN_ON_UNINTENTIONAL_PASSTHROUGH"RAISE_ON_UNINTENTIONAL_PASSTHROUGHrG   rG   rG   rI   r    s    r  c                   @  s   e Zd ZdZdddZed ddZed!d
dZed ddZed ddZ	ee
d"ddZed ddZee
d"ddZed#ddZee
d$ddZdS )%unsafezwContains static methods that should not normally be called during
    workflow execution except in advanced cases.
    rD   r   c                 C     t rF   NotImplementedErrorr   rG   rG   rI   rc     rK   zunsafe.__init__rR   c                   C     t tddS )zWhether the code is executing on a sandboxed thread.

        Returns:
            True if the code is executing in the sandbox thread.
        valueF)r   _in_sandboxrG   rG   rG   rI   
in_sandbox  r  zunsafe.in_sandboxvc                 C  s
   | t _d S rF   )r  r  )r  rG   rG   rI   _set_in_sandbox  s   
zunsafe._set_in_sandboxc                   C  r   )zWhether the workflow is currently replaying.

        Returns:
            True if the workflow is currently replaying
        )r   r   r  rG   rG   rG   rI   is_replaying  r  zunsafe.is_replayingc                   C  r  )zWhether the current block of code is not restricted via sandbox.

        Returns:
            True if the current code is not restricted in the sandbox.
        r  F)r   _sandbox_unrestrictedrG   rG   rG   rI   is_sandbox_unrestricted  r   zunsafe.is_sandbox_unrestrictedIterator[None]c                   c  6    t  r
dV  dS dt_z	dV  W dt_dS dt_w )z;A context manager to run code without sandbox restrictions.NTF)r  r  r  r  rG   rG   rG   rI   sandbox_unrestricted  s   zunsafe.sandbox_unrestrictedc                   C  r  )zWhether the current block of code is in
        :py:meth:imports_passed_through.

        Returns:
            True if the current code's imports will be passed through
        r  F)r   _imports_passed_throughrG   rG   rG   rI   is_imports_passed_through  r   z unsafe.is_imports_passed_throughc                   c  r  )zContext manager to mark all imports that occur within it as passed
        through (meaning not reloaded by the sandbox).
        NTF)r  r  r  r  rG   rG   rG   rI   imports_passed_through  s   zunsafe.imports_passed_through)Optional[SandboxImportNotificationPolicy]c                  C  s   t tdd} | S )zCGets the current import notification policy override if one is set.r  N)r   ,_sandbox_import_notification_policy_override)applied_policyrG   rG   rI   +current_import_notification_policy_override  s   z2unsafe.current_import_notification_policy_overridepolicyr  c                 c  s6    t tdd }t_| t_z	dV  W |t_dS |t_w )z>Context manager to apply the given import notification policy.r  N)r   r  r  )r  original_policyrG   rG   rI   "sandbox_import_notification_policy  s   
z)unsafe.sandbox_import_notification_policyNrq  r   )r  rR   rD   r   )rD   r  )rD   r  )r  r  rD   r  )r^   rq   rl   rr   rc   r~  r  r  r  r  r   r  r  r  r  r  rG   rG   rG   rI   r    s0    
r  c                      sH   e Zd ZdZd fdd	ZdddZd fddZedddZ  Z	S )LoggerAdaptera  Adapter that adds details to the log about the running workflow.

    Attributes:
        workflow_info_on_message: Boolean for whether a string representation of
            a dict of some workflow info will be appended to each message.
            Default is True.
        workflow_info_on_extra: Boolean for whether a ``temporal_workflow``
            dictionary value will be added to the ``extra`` dictionary with some
            workflow info, making it present on the ``LogRecord.__dict__`` for
            use by others. Default is True.
        full_workflow_info_on_extra: Boolean for whether a ``workflow_info``
            value will be added to the ``extra`` dictionary with the entire
            workflow info, making it present on the ``LogRecord.__dict__`` for
            use by others. Default is False.
        log_during_replay: Boolean for whether logs should occur during replay.
            Default is False.

    Values added to ``extra`` are merged with the ``extra`` dictionary from a
    logging call, with values from the logging call taking precedence. I.e. the
    behavior is that of ``merge_extra=True`` in Python >= 3.13.
    loggerlogging.Loggerextrar  rD   r   c                   s.   t  ||pi  d| _d| _d| _d| _dS )zCreate the logger adapter.TFN)r  rc   workflow_info_on_messageworkflow_info_on_extrafull_workflow_info_on_extralog_during_replay)r   r  r  r  rG   rI   rc      s
   
zLoggerAdapter.__init__msgr   r  MutableMapping[str, Any]$Tuple[Any, MutableMapping[str, Any]]c           	      C  s   i }i }| j s| js| jrJt }|r.|j}| j r|| | jr%||d< | jr.| |d< t }|rJ|j	}| j r>|| | jrJ|
di | i ||dpSi |d< |ra| d| d}||fS )z!Override to add workflow details.temporal_workflowr  r   ())r  r  r  r   r   r  r  r  r  r   
setdefaultr  )	r   r  r  r  	msg_extrar   workflow_detailsupdate_infoupdate_detailsrG   rG   rI   process*  s8   

zLoggerAdapter.processlevelr   rR   c                   s   | j s	t r	dS t |S )zOverride to ignore replay logs.F)r  r  r  r  isEnabledFor)r   r
  r  rG   rI   r  L  s   zLoggerAdapter.isEnabledForc                 C  s   | j S )zYUnderlying logger usable for actions such as adding
        handlers/formatters.
        )r  r   rG   rG   rI   base_loggerR  s   zLoggerAdapter.base_logger)r  r  r  r  rD   r   )r  r   r  r  rD   r   )r
  r   rD   rR   )rD   r  )
r^   rq   rl   rr   rc   r	  r  r   r  r  rG   rG   r  rI   r  	  s    

"r  c                   @  s   e Zd ZU ded< ded< ded< ded< d	ed
< ded< ded< ded< dZded< dZded< dZded< dZded< ed2ddZ	ed3ddZ
ed4d"d#Zed5d$d%Zed6d)d*Zed7d.d/Zd8d0d1ZdS )9r\   rQ   rM   r    rC   zCallable[..., Awaitable]run_fnz)Mapping[Optional[str], _SignalDefinition]signalsz(Mapping[Optional[str], _QueryDefinition]queriesz)Mapping[Optional[str], _UpdateDefinition]r#  rR   rN   rS   rO   NOptional[List[Type]]	arg_typesr!  ret_typez.Optional[temporalio.common.VersioningBehavior]rP   z.Optional[Callable[..., DynamicWorkflowConfig]]dynamic_config_fnrD   Optional[_Definition]c                 C  s"   t | dd }|r|j| kr|S d S N__temporal_workflow_definition)r   rC   )rC   rJ   rG   rG   rI   
from_classq  s   z_Definition.from_classc                 C  .   t | }|r	|S t| dd}td| d)Nr^   	<unknown>z	Workflow z: missing attributes, was it decorated with @workflow.defn?)r\   r  r   re   )rC   retcls_namerG   rG   rI   must_from_classy     

z_Definition.must_from_classrh   Callable[..., Awaitable[Any]]c                 C     t | dd S r  r   rm   rG   rG   rI   from_run_fn  r  z_Definition.from_run_fnc                 C  r  )Nrl   r  z	Function zi missing attributes, was it decorated with @workflow.run and was its class decorated with @workflow.defn?)r\   r!  r   re   )rh   r  fn_namerG   rG   rI   must_from_run_fn  r  z_Definition.must_from_run_fnname_or_run_fn)Union[str, Callable[..., Awaitable[Any]]]Tuple[str, Optional[Type]]c                 C  sF   t |tr	|d fS t|r| |}|jstd|j|jfS td)Nz)Cannot invoke dynamic workflow explicitlyz%Workflow must be a string or callable)r  r   callabler#  rM   re   r  	TypeError)rC   r$  rJ   rG   rG   rI   get_name_and_result_type  s   

z$_Definition.get_name_and_result_typer[   rT   r   c                C  s\  t | r	tdg }d }d }d }d}	i }
i }i }t| D ]\}}t|drQd}	t|| s<|d| d| j  q|d urN|d| d|j	 d	 q|}qt|d
rt
tt|d
}|j|
v r|jpgd}t
t|
|j j}|d| d| d|j	 d	 q||
|j< qt|drt
tt|d}|j|v r|jpd}|d| d| d||j jj	 d	 q|||j< q|dkrt|dr|}qt|dr|r|d| d| j	 d |r|d |}qt|tr/|j}|j|v r|jpd}|d| d| d||j jj	 d	 q|jr*t|j|js*|d|jj	 d|jj	 d q|||j< qt| dd  D ]}t|D ]\}}t|rPt||sRq@t|drpd}	|rd|j	|j	krn|d|j d q@t|d
rt
tt|d
}|j|
vr|d|j d q@t|drt
tt|d}|j|vr|d|j d q@t|tr|j}|j|vr|d |j d q@q9|	s|d! |r|rt||s|d" |rt|dkrtd#|d$  td%t| d&d'| |sJ |	sJ t || ||
||||||d(
}t| d)| t|d)| d S )*Nz*Class already contains workflow definitionFri   Tz@workflow.run method z must be defined on z2Multiple @workflow.run methods found (at least on z and r  r   z	<dynamic>z"Multiple signal methods found for z (at least on r   z!Multiple query methods found for rc   rd   r   zS@workflow.dynamic_config can only be used in dynamic workflows, but workflow class r  z) is not dynamicz>@workflow.dynamic_config can only be defined once per workflowz"Multiple update methods found for zUpdate validator method z' parameters do not match update method z parametersr-   z@workflow.run defined on z but not on the overridez@workflow.signal defined on z@workflow.query defined on z@workflow.update defined on zMissing @workflow.run methodz?@workflow.init and @workflow.run method parameters do not matchzInvalid workflow class: r   zInvalid workflow class for z
 reasons: z, )
rM   rC   r  r  r  r#  rN   rO   rP   r  r  )r\   r  re   rj   
getmembersr   _is_unbound_method_on_clsappendrl   r^   r#   r   r   rM   r   rh   r   r  r  r  r0  "_parameters_identical_up_to_naminggetmro
isfunctionr   joinrf   )rC   r[   rN   rO   rP   issuesrb   r  r  seen_run_attrr  r  r#  rM   membersignal_defn	defn_nameother_fn
query_defnupdate_defnbase_cls_base_memberrJ   rG   rG   rI   r]     s<  















%


z_Definition._apply_to_classc                 C  s   | j d u r@| jd u rB| jd u }tj| j\}}|r0|r,t|dks,|d ttjj	 kr0t
dt| d| t| d| d S d S d S )Nr-   r   zJDynamic workflow must accept a single Sequence[temporalio.common.RawValue]r  r  )r  r  rM   r   r   _type_hints_from_funcr  r   r   RawValuer(  object__setattr__)r   rX   r  r  rG   rG   rI   __post_init__C  s   
z_Definition.__post_init__)rC   r    rD   r  )rC   r    rD   r\   )rh   r  rD   r  )rh   r  rD   r\   )r$  r%  rD   r&  )rC   r    r[   rQ   rN   rR   rO   rS   rP   rT   rD   r   rq  )r^   rq   rl   r   r  r  rP   r  r~  r  r  r!  r#  classmethodr)  r]   r@  rG   rG   rG   rI   r\   a  s6   
 		 $r\   fn1r   fn2c                 C  s   ddd}|| ||kS )	zVReturn True if the functions have identical parameter lists, ignoring parameter names.rh   r   rD   List[inspect.Parameter]c                 S  s   dd t | j D S )Nc                 S  s   g | ]}|j d dqS )xrM   )replace).0prG   rG   rI   
<listcomp>Z  s    zF_parameters_identical_up_to_naming.<locals>.params.<locals>.<listcomp>)rj   r   r   r   rm   rG   rG   rI   r   W  s   z2_parameters_identical_up_to_naming.<locals>.paramsN)rh   r   rD   rD  rG   )rB  rC  r   rG   rG   rI   r-  T  s   
r-  objCallable[..., Any]c                   s>   t  rttdtt f   d fdd}|S t S )N.rD   r   c                    s    g| R i |I d H S rF   rG   r  r  rh   rK  rG   rI   with_objectj  s   z!_bind_method.<locals>.with_objectrt  )rj   rk   r#   r   r   r   r   )rK  rh   rO  rG   rN  rI   _bind_methodb  s
   

rP  r  r  r   c                 C  s   t t| j }|rdnd}t||kr*|d jtjju r*|d jtjj	u r*dS |rBt|dksB|d t
ksB|d ttjj krFtdd	S )
N   rp   Fr   r-   zZDynamic handler must have 3 arguments: self, str, and Sequence[temporalio.common.RawValue]T)r   rj   r   r   r   r   kind	ParameterPOSITIONAL_OR_KEYWORDVAR_POSITIONALr   r   r   r   r=  r   )rh   r  r   r   total_expected_paramsrG   rG   rI   _assert_dynamic_handler_argsr  s   rY  c                   @  s   e Zd ZU ded< ded< ded< ejZded< d	Zded
< d	Zded< dZ	ded< e
d!ddZe
d"ddZd#ddZd$dd Zd	S )%r   rQ   rM   z+Callable[..., Union[None, Awaitable[None]]]rh   rR   r   ro   r}   Nr~   r  r  Fr   r   rD   Optional[_SignalDefinition]c                 C  r  )Nr   r   rm   rG   rG   rI   from_fn  r  z_SignalDefinition.from_fnrz   Union[str, Callable]r   c                 C  sD   t | rt| }|std| j d|jstd|jS t| S )NzSignal definition not found on z(, is it decorated with @workflow.signal?z'Cannot invoke dynamic signal definition)r'  r   r[  r   rl   rM   r   )rz   rJ   rG   rG   rI   must_name_from_fn_or_str  s   
z*_SignalDefinition.must_name_from_fn_or_strr   c                 C  sT   | j d u r(tj| j\}}| jst| dt| j|| j	  t| d| d S d S )Nr   r  )
r  r   r   r<  rh   rM   r>  r?  rY  r   )r   r  r:  rG   rG   rI   r@    s   

z_SignalDefinition.__post_init__rK  r   rL  c                 C     t || jS rF   rP  rh   r   rK  rG   rG   rI   bind_fn     z_SignalDefinition.bind_fn)rh   r   rD   rZ  )rz   r\  rD   r   rq  rK  r   rD   rL  )r^   rq   rl   r   ro   rs   r}   r~   r  r   r~  r[  r]  r@  ra  rG   rG   rG   rI   r     s   
 

r   c                   @  sx   e Zd ZU ded< ded< ded< dZded< dZd	ed
< dZded< dZded< edddZ	dddZ
dddZdS )r   rQ   rM   rL  rh   rR   r   Nr~   r  r  r!  r  Fr   r   rD   Optional[_QueryDefinition]c                 C  r  )Nr   r   rm   rG   rG   rI   r[    r  z_QueryDefinition.from_fnr   c                 C  sp   | j d u r4| jd u r6tj| j\}}| js$t| dt	| j|| j
  t| d| t| d| d S d S d S )Nr   r  r  )r  r  r   r   r<  rh   rM   r>  r?  rY  r   r   r  r  rG   rG   rI   r@    s   
z_QueryDefinition.__post_init__rK  r   c                 C  r^  rF   r_  r`  rG   rG   rI   ra    rb  z_QueryDefinition.bind_fn)rh   r   rD   rd  rq  rc  )r^   rq   rl   r   r~   r  r  r   r~  r[  r@  ra  rG   rG   rG   rI   r     s   
 
r   c                   @  s   e Zd ZU ded< ded< ded< ejZded< d	Zded
< d	Zded< d	Z	ded< d	Z
ded< dZded< d&ddZd'ddZd'ddZd(dd Zed)d$d%Zd	S )*r  rQ   rM   z)Callable[..., Union[Any, Awaitable[Any]]]rh   rR   r   ro   r}   Nr~   r  r  r!  r  r  r0  Fr   rD   r   c                 C  s^   | j d u r-tj| j\}}| jst| j|| jstdt	
| d| t	
| d| d S d S )Nr  r  r  )r  r   r   r<  rh   rM   rY  r   r   r>  r?  re  rG   rG   rI   r@    s   

z_UpdateDefinition.__post_init__rK  r   rL  c                 C  r^  rF   r_  r`  rG   rG   rI   ra     rb  z_UpdateDefinition.bind_fnc                 C  s   | j d urt|| j S dd S )Nc                  _  rE   rF   rG   rM  rG   rG   rI   <lambda>  s    z2_UpdateDefinition.bind_validator.<locals>.<lambda>)r0  rP  r`  rG   rG   rI   bind_validator  s   
z _UpdateDefinition.bind_validatorCallable[..., None]c                 C  s(   | j rtd| j t| d| d S )Nz!Validator already set for update r0  )r0  r   rM   r>  r?  )r   r0  rG   rG   rI   r    s   z_UpdateDefinition.set_validatorname_or_update_fnUnion[str, Callable[..., Any]]r&  c                 C  s:   t |tjjr|j}|jstd|j|jfS t|d fS )Nz'Cannot invoke dynamic update definition)	r  r   r  r  r  rM   r   r  r   )rC   ri  rJ   rG   rG   rI   r)    s   z*_UpdateDefinition.get_name_and_result_typerq  rc  )r0  rh  rD   r   )ri  rj  rD   r&  )r^   rq   rl   r   ro   rs   r}   r~   r  r  r0  r   r@  ra  rg  r  rA  r)  rG   rG   rG   rI   r    s"   
 




c                   @     e Zd ZdS _AsyncioTaskNr^   rq   rl   rG   rG   rG   rI   rm        rm  c                   @  rk  rl  rn  rG   rG   rG   rI   rm  $  ro  c                   @  ru   )ActivityHandlezHandle returned from :py:func:`start_activity` and
    :py:func:`start_local_activity`.

    This extends :py:class:`asyncio.Task` and supports all task features.
    Nrw   rG   rG   rG   rI   rp  (  s    rp  c                   @  sF   e Zd ZdZeejjjj	j
Z
eejjjj	jZeejjjj	jZdS )r:  z/How an activity cancellation should be handled.N)r^   rq   rl   rr   r   r   bridgeprotoworkflow_commandsr:  
TRY_CANCELWAIT_CANCELLATION_COMPLETEDrt   rG   rG   rG   rI   r:  2  s    r:  c                   @  sj   e Zd ZU dZded< ded< ded< ded< ded< d	ed
< ded< ded< ded< ded< ded< dS )ActivityConfigzlTypedDict of config that can be used for :py:func:`start_activity` and
    :py:func:`execute_activity`.
    rQ   r   r   r5  r6  r7  r8  r   r   r:  r9  r;  r  r  r2  r   r   Nr   rG   rG   rG   rI   rv  @  s   
 rv  )total)r   r5  r6  r7  r8  r   r9  r;  r  r2  r   r3   CallableAsyncNoParam[ReturnType]r   r5  r   r6  r7  r8  r   r   r9  r;  r  r  r   r   ActivityHandle[ReturnType]c                C  rE   rF   rG   r3  r   r5  r6  r7  r8  r   r9  r;  r  r2  r   rG   rG   rI   start_activityS     r{  CallableSyncNoParam[ReturnType]c                C  rE   rF   rG   rz  rG   rG   rI   r{  f  r|  /CallableAsyncSingleParam[ParamType, ReturnType]argc                C  rE   rF   rG   r3  r  r   r5  r6  r7  r8  r   r9  r;  r  r2  r   rG   rG   rI   r{  y     .CallableSyncSingleParam[ParamType, ReturnType]c                C  rE   rF   rG   r  rG   rG   rI   r{    r  $Callable[..., Awaitable[ReturnType]]r  Sequence[Any]c                C  rE   rF   rG   r3  r  r   r5  r6  r7  r8  r   r9  r;  r  r2  r   rG   rG   rI   r{    r  Callable[..., ReturnType]c                C  rE   rF   rG   r  rG   rG   rI   r{    r  )r  r   r4  r5  r6  r7  r8  r   r9  r;  r  r2  r   r4  Optional[type]r<  c                C  rE   rF   rG   r3  r  r  r   r4  r5  r6  r7  r8  r   r9  r;  r  r2  r   rG   rG   rI   r{    s   c                C  s<   t  j| gtj||R |||||||	|
||||dS )a  Start an activity and return its handle.

    At least one of ``schedule_to_close_timeout`` or ``start_to_close_timeout``
    must be present.

    Args:
        activity: Activity name or function reference.
        arg: Single argument to the activity.
        args: Multiple arguments to the activity. Cannot be set if arg is.
        task_queue: Task queue to run the activity on. Defaults to the current
            workflow's task queue.
        result_type: For string activities, this can set the specific result
            type hint to deserialize into.
        schedule_to_close_timeout: Max amount of time the activity can take from
            first being scheduled to being completed before it times out. This
            is inclusive of all retries.
        schedule_to_start_timeout: Max amount of time the activity can take to
            be started from first being scheduled.
        start_to_close_timeout: Max amount of time a single activity run can
            take from when it starts to when it completes. This is per retry.
        heartbeat_timeout: How frequently an activity must invoke heartbeat
            while running before it is considered timed out.
        retry_policy: How an activity is retried on failure. If unset, a
            server-defined default is used. Set maximum attempts to 1 to disable
            retries.
        cancellation_type: How the activity is treated when it is cancelled from
            the workflow.
        activity_id: Optional unique identifier for the activity. This is an
            advanced setting that should not be set unless users are sure they
            need to. Contact Temporal before setting this value.
        versioning_intent: When using the Worker Versioning feature, specifies whether this Activity
            should run on a worker with a compatible Build Id or not.
            Deprecated: Use Worker Deployment versioning instead.
        summary: A single-line fixed summary for this activity that may appear in UI/CLI.
            This can be in single-line Temporal markdown format.
        priority: Priority of the activity.

    Returns:
        An activity handle to the activity which is an async task.
    r   r4  r5  r6  r7  r8  r   r9  r;  r  r2  r   r   r   r=  r   r   _arg_or_argsr  rG   rG   rI   r{    s$   :rA   c                  rF  rF   rG   rz  rG   rG   rI   execute_activity+	     r  c                  rF  rF   rG   rz  rG   rG   rI   r  >	  r  c                  rF  rF   rG   r  rG   rG   rI   r  Q	     c                  rF  rF   rG   r  rG   rG   rI   r  e	  r  c                  rF  rF   rG   r  rG   rG   rI   r  y	  r  c                  rF  rF   rG   r  rG   rG   rI   r  	  r  c                  rF  rF   rG   r  rG   rG   rI   r  	  s   c                  sD   t  j| gtj||R |||||||	|
||||dI dH S )zpStart an activity and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_activity`.
    r  Nr  r  rG   rG   rI   r  	  s&   &Type[CallableAsyncNoParam[ReturnType]]c                C  rE   rF   rG   rz  rG   rG   rI   start_activity_class	  r|  r  %Type[CallableSyncNoParam[ReturnType]]c                C  rE   rF   rG   rz  rG   rG   rI   r  	  r|  5Type[CallableAsyncSingleParam[ParamType, ReturnType]]c                C  rE   rF   rG   r  rG   rG   rI   r  
  r  4Type[CallableSyncSingleParam[ParamType, ReturnType]]c                C  rE   rF   rG   r  rG   rG   rI   r  
  r  *Type[Callable[..., Awaitable[ReturnType]]]c                C  rE   rF   rG   r  rG   rG   rI   r  /
  r  Type[Callable[..., ReturnType]]c                C  rE   rF   rG   r  rG   rG   rI   r  C
  r  )r  r   r5  r6  r7  r8  r   r9  r;  r  r2  r   Type[Callable]c                C  <   t  j| gtj||R |d||||||	|
|||dS )zrStart an activity from a callable class.

    See :py:meth:`start_activity` for parameter and return details.
    Nr  r  r3  r  r  r   r5  r6  r7  r8  r   r9  r;  r  r2  r   rG   rG   rI   r  V
  $   c                  rF  rF   rG   rz  rG   rG   rI   execute_activity_class~
  r  r  c                  rF  rF   rG   rz  rG   rG   rI   r  
  r  c                  rF  rF   rG   r  rG   rG   rI   r  
  r  c                  rF  rF   rG   r  rG   rG   rI   r  
  r  c                  rF  rF   rG   r  rG   rG   rI   r  
  r  c                  rF  rF   rG   r  rG   rG   rI   r  
  r  c                  D   t  j| gtj||R |d||||||	|
|||dI dH S )zStart an activity from a callable class and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_activity_class`.
    Nr  r  r  rG   rG   rI   r  
  s&   (MethodAsyncNoParam[SelfType, ReturnType]c                C  rE   rF   rG   rz  rG   rG   rI   start_activity_method  r|  r  'MethodSyncNoParam[SelfType, ReturnType]c                C  rE   rF   rG   rz  rG   rG   rI   r  .  r|  7MethodAsyncSingleParam[SelfType, ParamType, ReturnType]c                C  rE   rF   rG   r  rG   rG   rI   r  A  r  6MethodSyncSingleParam[SelfType, ParamType, ReturnType]c                C  rE   rF   rG   r  rG   rG   rI   r  U  r  FCallable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]]c                C  rE   rF   rG   r  rG   rG   rI   r  i  r  ;Callable[Concatenate[SelfType, MultiParamSpec], ReturnType]c                C  rE   rF   rG   r  rG   rG   rI   r  }  r  c                C  r  )zjStart an activity from a method.

    See :py:meth:`start_activity` for parameter and return details.
    Nr  r  r  rG   rG   rI   r    r  c                  rF  rF   rG   rz  rG   rG   rI   execute_activity_method  r  r  c                  rF  rF   rG   rz  rG   rG   rI   r    r  c                  rF  rF   rG   r  rG   rG   rI   r    r  c                  rF  rF   rG   r  rG   rG   rI   r    r  c                  rF  rF   rG   r  rG   rG   rI   r    r  c                  rF  rF   rG   r  rG   rG   rI   r    r  c                  r  )zStart an activity from a method and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_activity_method`.
    Nr  r  r  rG   rG   rI   r  -  s&   c                   @  sR   e Zd ZU dZded< ded< ded< ded< ded< d	ed
< ded< ded< dS )LocalActivityConfigzxTypedDict of config that can be used for :py:func:`start_local_activity`
    and :py:func:`execute_local_activity`.
    r   r5  r6  r7  r   r   rI  r:  r9  rQ   r;  r2  Nr   rG   rG   rG   rI   r  V  s   
 r  )r5  r6  r7  r   rI  r9  r;  r2  rI  c          	      C  rE   rF   rG   	r3  r5  r6  r7  r   rI  r9  r;  r2  rG   rG   rI   start_local_activityf     r  )r;  r5  r6  r7  r   rI  r9  r2  c          	      C  rE   rF   rG   )	r3  r;  r5  r6  r7  r   rI  r9  r2  rG   rG   rI   r  v  r  c          
      C  rE   rF   rG   
r3  r  r5  r6  r7  r   rI  r9  r;  r2  rG   rG   rI   r       c          
      C  rE   rF   rG   r  rG   rG   rI   r    r  c       	   
      C  rE   rF   rG   
r3  r  r5  r6  r7  r   rI  r9  r;  r2  rG   rG   rI   r    r  c       	   
      C  rE   rF   rG   r  rG   rG   rI   r    r  )
r  r4  r5  r6  r7  r   rI  r9  r;  r2  c       
         C  rE   rF   rG   r3  r  r  r4  r5  r6  r7  r   rI  r9  r;  r2  rG   rG   rI   r    r|  c       
         C  s6   t  j| gtj||R |||||||	|
|d	S )a+  Start a local activity and return its handle.

    At least one of ``schedule_to_close_timeout`` or ``start_to_close_timeout``
    must be present.

    Args:
        activity: Activity name or function reference.
        arg: Single argument to the activity.
        args: Multiple arguments to the activity. Cannot be set if arg is.
        result_type: For string activities, this can set the specific result
            type hint to deserialize into.
        schedule_to_close_timeout: Max amount of time the activity can take from
            first being scheduled to being completed before it times out. This
            is inclusive of all retries.
        schedule_to_start_timeout: Max amount of time the activity can take to
            be started from first being scheduled.
        start_to_close_timeout: Max amount of time a single activity run can
            take from when it starts to when it completes. This is per retry.
        retry_policy: How an activity is retried on failure. If unset, an
            SDK-defined default is used. Set maximum attempts to 1 to disable
            retries.
        cancellation_type: How the activity is treated when it is cancelled from
            the workflow.
        activity_id: Optional unique identifier for the activity. This is an
            advanced setting that should not be set unless users are sure they
            need to. Contact Temporal before setting this value.
        summary: Optional summary for the activity.

    Returns:
        An activity handle to the activity which is an async task.
    	r4  r5  r6  r7  r   rI  r9  r;  r2  r   r   rJ  r   r   r  r  rG   rG   rI   r    s   .c          	        rF  rF   rG   r  rG   rG   rI   execute_local_activity     r  c          	        rF  rF   rG   r  rG   rG   rI   r  *  r  c          
        rF  rF   rG   r  rG   rG   rI   r  :     c          
        rF  rF   rG   r  rG   rG   rI   r  K  r  c       	   
        rF  rF   rG   r  rG   rG   rI   r  \  r  c       	   
        rF  rF   rG   r  rG   rG   rI   r  m  r  c       
           rF  rF   rG   r  rG   rG   rI   r  ~  r  c       
           s>   t  j| gtj||R |||||||	|
|d	I dH S )z{Start a local activity and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_local_activity`.
    r  Nr  r  rG   rG   rI   r    s    )r5  r6  r7  r   rI  r9  r;  c                C  rE   rF   rG   r3  r5  r6  r7  r   rI  r9  r;  rG   rG   rI   start_local_activity_class     r  c                C  rE   rF   rG   r  rG   rG   rI   r    r  c          	      C  rE   rF   rG   	r3  r  r5  r6  r7  r   rI  r9  r;  rG   rG   rI   r    r  c          	      C  rE   rF   rG   r  rG   rG   rI   r    r  c          	      C  rE   rF   rG   	r3  r  r5  r6  r7  r   rI  r9  r;  rG   rG   rI   r    r  c          	      C  rE   rF   rG   r  rG   rG   rI   r    r  )	r  r5  r6  r7  r   rI  r9  r;  r2  c       	         C  6   t  j| gtj||R d|||||||	|
d	S )z}Start a local activity from a callable class.

    See :py:meth:`start_local_activity` for parameter and return details.
    Nr  r  r3  r  r  r5  r6  r7  r   rI  r9  r;  r2  rG   rG   rI   r       c          	        rF  rF   rG   r  rG   rG   rI   execute_local_activity_class4  r  r  c          	        rF  rF   rG   r  rG   rG   rI   r  D  r  c          
        rF  rF   rG   r  rG   rG   rI   r  T  r  c          
        rF  rF   rG   r  rG   rG   rI   r  e  r  c       	   
        rF  rF   rG   r  rG   rG   rI   r  v  r  c       	   
        rF  rF   rG   r  rG   rG   rI   r    r  c       	           >   t  j| gtj||R d|||||||	|
d	I dH S )zStart a local activity from a callable class and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_local_activity_class`.
    Nr  r  r  rG   rG   rI   r        c          	      C  rE   rF   rG   r  rG   rG   rI   start_local_activity_method  r  r  c          	      C  rE   rF   rG   r  rG   rG   rI   r    r  c          
      C  rE   rF   rG   r  rG   rG   rI   r    r  c          
      C  rE   rF   rG   r  rG   rG   rI   r    r  c       	   
      C  rE   rF   rG   r  rG   rG   rI   r    r  c       	   
      C  rE   rF   rG   r  rG   rG   rI   r    r  c       	         C  r  )zuStart a local activity from a method.

    See :py:meth:`start_local_activity` for parameter and return details.
    Nr  r  r  rG   rG   rI   r    r  c          	        rF  rF   rG   r  rG   rG   rI   execute_local_activity_method@  r  r  c          	        rF  rF   rG   r  rG   rG   rI   r  P  r  c          
        rF  rF   rG   r  rG   rG   rI   r  `  r  c          
        rF  rF   rG   r  rG   rG   rI   r  q  r  c       	   
        rF  rF   rG   r  rG   rG   rI   r    r  c       	   
        rF  rF   rG   r  rG   rG   rI   r    r  c       	           r  )zStart a local activity from a method and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_local_activity_method`.
    Nr  r  r  rG   rG   rI   r    r  c                   @  s   e Zd ZdZedddZedddZedddZedddZed ddZee	j
jfg dd!ddZe	j
jfg dd"ddZdS )#ChildWorkflowHandlezHandle for interacting with a child workflow.

    This is created via :py:func:`start_child_workflow`.

    This extends :py:class:`asyncio.Task` and supports all task features.
    rD   r   c                 C  r  zID for the workflow.r  r   rG   rG   rI   r     r{   zChildWorkflowHandle.idrQ   c                 C  r  )zRun ID for the workflow.r  r   rG   rG   rI   r     r{   z*ChildWorkflowHandle.first_execution_run_idrz   (MethodSyncOrAsyncNoParam[SelfType, None]r   c                   rF  rF   rG   r   rz   rG   rG   rI   rz        zChildWorkflowHandle.signal7MethodSyncOrAsyncSingleParam[SelfType, ParamType, None]r  r?   c                   rF  rF   rG   r   rz   r  rG   rG   rI   rz        MCallable[Concatenate[SelfType, MultiParamSpec], Union[Awaitable[None], None]]r  r  c                  rF  rF   rG   )r   rz   r  rG   rG   rI   rz     s   r  r   c                  rF  rF   rG   r   rz   r  r  rG   rG   rI   rz     re  r\  c                     t )zSignal this child workflow.

        Args:
            signal: Name or method reference for the signal.
            arg: Single argument to the signal.
            args: Multiple arguments to the signal. Cannot be set if arg is.

        r  r  rG   rG   rI   rz     r  Nr   rD   rQ   rz   r  rD   r   rz   r  r  r?   rD   r   )rz   r  r  r  rD   r   rz   r   r  r   r  r  rD   r   rz   r\  r  r   r  r  rD   r   )r^   rq   rl   rr   r   r   r   r$   rz   r   r   
_arg_unsetrG   rG   rG   rI   r    s*    	r  c                   @  sX   e Zd ZdZeejjjj	j
Z
eejjjj	jZeejjjj	jZeejjjj	jZdS )r@  z4How a child workflow cancellation should be handled.N)r^   rq   rl   rr   r   r   rq  rr  child_workflowr@  rt   rt  ru  WAIT_CANCELLATION_REQUESTEDrG   rG   rG   rI   r@  
      r@  c                   @  sX   e Zd ZdZeejjjj	j
Zeejjjj	jZeejjjj	jZeejjjj	jZdS )rB  z>How a child workflow should be handled when the parent closes.N)r^   rq   rl   rr   r   r   rq  rr  r  rB  PARENT_CLOSE_POLICY_UNSPECIFIEDr   PARENT_CLOSE_POLICY_TERMINATE	TERMINATEPARENT_CLOSE_POLICY_ABANDONrt   "PARENT_CLOSE_POLICY_REQUEST_CANCELREQUEST_CANCELrG   rG   rG   rI   rB    r  rB  c                   @  s   e Zd ZU dZded< ded< ded< ded< d	ed
< d	ed< d	ed< ded< ded< ded< ded< ded< ded< ded< ded< ded< dS )ChildWorkflowConfigzxTypedDict of config that can be used for :py:func:`start_child_workflow`
    and :py:func:`execute_child_workflow`.
    rQ   r   r   r@  r9  rB  rA  r   r   r   r   rD  rC  r   r   r   r   r  r
  r  r   r  r  r>  r?  r   r   Nr   rG   rG   rG   rI   r  ,  s$   
 r   )r   r   r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   r  rA  r   r   r   rC  rD  r   r  r   r  r>  r?  )ChildWorkflowHandle[SelfType, ReturnType]c                  rF  rF   rG   r  r   r   r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   rG   rG   rI   start_child_workflowH     r  c                  rF  rF   rG   r  r  r   r   r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   rG   rG   rI   r  d     c                  rF  rF   rG   r  r  r   r   r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   rG   rG   rI   r    r  )r  r   r   r4  r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   rE  c                  rF  rF   rG   r  r  r  r   r   r4  r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   rG   rG   rI   r    rH  c                  s  t j| t j| gt j||R i d|pStt d|d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|I dH S d|d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|I dH S )a<	  Start a child workflow and return its handle.

    Args:
        workflow: String name or class method decorated with ``@workflow.run``
            for the workflow to start.
        arg: Single argument to the child workflow.
        args: Multiple arguments to the child workflow. Cannot be set if arg is.
        id: Optional unique identifier for the workflow execution. If not set,
            defaults to :py:func:`uuid4`.
        task_queue: Task queue to run the workflow on. Defaults to the current
            workflow's task queue.
        result_type: For string workflows, this can set the specific result type
            hint to deserialize into.
        cancellation_type: How the child workflow will react to cancellation.
        parent_close_policy: How to handle the child workflow when the parent
            workflow closes.
        execution_timeout: Total workflow execution timeout including
            retries and continue as new.
        run_timeout: Timeout of a single workflow run.
        task_timeout: Timeout of a single workflow task.
        id_reuse_policy: How already-existing IDs are treated.
        retry_policy: Retry policy for the workflow.
        cron_schedule: See https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
        memo: Memo for the workflow.
        search_attributes: Search attributes for the workflow. The dictionary
            form of this is DEPRECATED.
        versioning_intent:  When using the Worker Versioning feature, specifies whether this Child
            Workflow should run on a worker with a compatible Build Id or not.
            Deprecated: Use Worker Deployment versioning instead.
        static_summary: A single-line fixed summary for this child workflow execution that may appear
            in the UI/CLI. This can be in single-line Temporal markdown format.
        static_details: General fixed details for this child workflow execution that may appear in
            UI/CLI. This can be in Temporal markdown format and can span multiple lines. This is
            a fixed value on the workflow that cannot be updated. For details that can be
            updated, use :py:meth:`Workflow.get_current_details` within the workflow.
        priority: Priority to use for this workflow.

    Returns:
        A workflow handle to the started/existing workflow.
    r   r   r4  r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   N	r   r   r  r   r   rG  r  r   r  r  rG   rG   rI   r    s   C	

	

c                  rF  rF   rG   r  rG   rG   rI   execute_child_workflow  r  r  c                  rF  rF   rG   r  rG   rG   rI   r  4  r  c                  rF  rF   rG   r  rG   rG   rI   r  Q  r  c                  rF  rF   rG   r  rG   rG   rI   r  n  rH  c                  s&  t j| t j| gt j||R i d|pXtt d|d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|I dH }|I dH S d|d|d|d|d|d|	d|
d	|d
|d|d|d|d|d|d|d|I dH }|I dH S )zStart a child workflow and wait for completion.

    This is a shortcut for ``await (await`` :py:meth:`start_child_workflow` ``)``.
    r   r   r4  r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   Nr  )r  r  r  r   r   r4  r9  rA  r   r   r   rC  r   r   r
  r   r  r>  r?  r   handlerG   rG   rI   r    s   	


	


c                   @  s2   e Zd ZdZdddZdddZedd
dZdS )NexusOperationHandleztHandle for interacting with a Nexus operation.

    .. warning::
        This API is experimental and unstable.
    rD   rR   c                 C  r  )z&Request cancellation of the operation.r  r   rG   rG   rI   cancel     zNexusOperationHandle.cancelGenerator[Any, Any, OutputT]c                 C  r  )zSupport await.r  r   rG   rG   rI   	__await__  r  zNexusOperationHandle.__await__rQ   c                 C  r  )z$The operation token for this handle.r  r   rG   rG   rI   operation_token  r{   z$NexusOperationHandle.operation_tokenNr   )rD   r  r  )r^   rq   rl   rr   r  r  r   r  rG   rG   rG   rI   r    s    

r  c                   @  s   e Zd ZdZedddZedddZedddZedddZee	j
jfg dd ddZe	j
jfg dd!ddZd"ddZdS )#ExternalWorkflowHandlezHandle for interacting with an external workflow.

    This is created via :py:func:`get_external_workflow_handle` or
    :py:func:`get_external_workflow_handle_for`.
    rD   r   c                 C  r  r  r  r   rG   rG   rI   r     r{   zExternalWorkflowHandle.idrQ   c                 C  r  )zRun ID for the workflow if any.r  r   rG   rG   rI   r     r{   zExternalWorkflowHandle.run_idrz   r  r   c                   rF  rF   rG   r  rG   rG   rI   rz     r  zExternalWorkflowHandle.signalr  r  r?   c                   rF  rF   rG   r  rG   rG   rI   rz     r  r  r   r  r  c                  rF  rF   rG   r  rG   rG   rI   rz     re  r\  c                  r  )zSignal this external workflow.

        Args:
            signal: Name or method reference for the signal.
            arg: Single argument to the signal.
            args: Multiple arguments to the signal. Cannot be set if arg is.

        r  r  rG   rG   rI   rz     r  c                   r  )zSend a cancellation request to this external workflow.

        This will fail if the workflow cannot accept the request (e.g. if the
        workflow is not found).
        r  r   rG   rG   rI   r       zExternalWorkflowHandle.cancelNr   r  r  r  r  r  rq  )r^   rq   rl   rr   r   r   r   r$   rz   r   r   r  r  rG   rG   rG   rI   r    s(    r  r   r   r   r  c                C  s   t  j| |dS )zGet a workflow handle to an existing workflow by its ID.

    Args:
        workflow_id: Workflow ID to get a handle to.
        run_id: Optional run ID for the workflow.

    Returns:
        The external workflow handle.
    r  )r   r   r  )r   r   rG   rG   rI   get_external_workflow_handle  s   r  TUnion[MethodAsyncNoParam[SelfType, Any], MethodAsyncSingleParam[SelfType, Any, Any]] ExternalWorkflowHandle[SelfType]c                C  s   t ||dS )a  Get a typed workflow handle to an existing workflow by its ID.

    This is the same as :py:func:`get_external_workflow_handle` but typed. Note,
    the workflow type given is not validated, it is only for typing.

    Args:
        workflow: The workflow run method to use for typing the handle.
        workflow_id: Workflow ID to get a handle to.
        run_id: Optional run ID for the workflow.

    Returns:
        The external workflow handle.
    r  )r  )r  r   r   rG   rG   rI    get_external_workflow_handle_for1  s   r  c                      "   e Zd ZdZd fddZ  ZS )	ContinueAsNewErrorzError thrown by :py:func:`continue_as_new`.

    This should not be caught, but instead be allowed to throw out of the
    workflow which then triggers the continue as new. This should never be
    instantiated directly.
    r  r>  rD   r   c                   s$   t | tkr
tdt j|  dS )zADirect instantiation is disabled. Use :py:func:`continue_as_new`.z.Cannot instantiate ContinueAsNewError directlyN)typer  r   r  rc   r   r  r  rG   rI   rc   Q  s   zContinueAsNewError.__init__r  r>  rD   r   r^   rq   rl   rr   rc   r  rG   rG   r  rI   r  I  s    r  )r  r   r   r   r   r
  r   r  r   c          	      C  rE   rF   rG   )	r  r  r   r   r   r   r
  r   r  rG   rG   rI   continue_as_newY  r  r  )r   r   r   r   r
  r   r  !MethodAsyncNoParam[SelfType, Any]c                 C  rE   rF   rG   r  r   r   r   r   r
  r   r  rG   rG   rI   r  m  r|  0MethodAsyncSingleParam[SelfType, ParamType, Any]c          	      C  rE   rF   rG   )	r  r  r   r   r   r   r
  r   r  rG   rG   rI   r    r  ?Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[Any]]c        	   	      C  rE   rF   rG   	r  r  r   r   r   r   r
  r   r  rG   rG   rI   r    r  c        	   	      C  rE   rF   rG   r  rG   rG   rI   r    r  )	r  r  r   r   r   r   r
  r   r  r	  c       	   
      C  s<   t j| t jt j| |||||||||	d dS )ar  Stop the workflow immediately and continue as new.

    Args:
        arg: Single argument to the continued workflow.
        args: Multiple arguments to the continued workflow. Cannot be set if arg
            is.
        workflow: Specific workflow to continue to. Defaults to the current
            workflow.
        task_queue: Task queue to run the workflow on. Defaults to the current
            workflow's task queue.
        run_timeout: Timeout of a single workflow run. Defaults to the current
            workflow's run timeout.
        task_timeout: Timeout of a single workflow task. Defaults to the current
            workflow's task timeout.
        memo: Memo for the workflow. Defaults to the current workflow's memo.
        search_attributes: Search attributes for the workflow. Defaults to the
            current workflow's search attributes. The dictionary form of this is
            DEPRECATED.
        versioning_intent: When using the Worker Versioning feature, specifies whether this Workflow
            should Continue-as-New onto a worker with a compatible Build Id or not.
            Deprecated: Use Worker Deployment versioning instead.

    Returns:
        Never returns, always raises a :py:class:`ContinueAsNewError`.

    Raises:
        ContinueAsNewError: Always raised by this function. Should not be caught
            but instead be allowed to
    r  N)r   r   r  r   r   r  r  )
r  r  r  r   r   r   r   r
  r   r  rG   rG   rI   r    s   .r  c                 C  r  )aT  Get the signal handler for the given name if any.

    This includes handlers created via the ``@workflow.signal`` decorator.

    Args:
        name: Name of the signal.

    Returns:
        Callable for the signal if any. If a handler is not found for the name,
        this will not return the dynamic handler even if there is one.
    r   r   r  rF  rG   rG   rI   get_signal_handler     r   r,  c                 C     t  | | dS )a  Set or unset the signal handler for the given name.

    This overrides any existing handlers for the given name, including handlers
    created via the ``@workflow.signal`` decorator.

    When set, all unhandled past signals for the given name are immediately sent
    to the handler.

    Args:
        name: Name of the signal.
        handler: Callable to set or None to unset.
    Nr   r   r/  rM   r,  rG   rG   rI   set_signal_handler  s   r  c                   C     t  dS )zGet the dynamic signal handler if any.

    This includes dynamic handlers created via the ``@workflow.signal``
    decorator.

    Returns:
        Callable for the dynamic signal handler if any.
    Nr  rG   rG   rG   rI   get_dynamic_signal_handler     	r  c                 C     t  d|  dS )a.  Set or unset the dynamic signal handler.

    This overrides the existing dynamic handler even if it was created via the
    ``@workflow.signal`` decorator.

    When set, all unhandled past signals are immediately sent to the handler.

    Args:
        handler: Callable to set or None to unset.
    Nr  r,  rG   rG   rI   set_dynamic_signal_handler"  s   r  c                 C  r  )aP  Get the query handler for the given name if any.

    This includes handlers created via the ``@workflow.query`` decorator.

    Args:
        name: Name of the query.

    Returns:
        Callable for the query if any. If a handler is not found for the name,
        this will not return the dynamic handler even if there is one.
    r   r   r  rF  rG   rG   rI   get_query_handler0  r  r  c                 C  r  )a  Set or unset the query handler for the given name.

    This overrides any existing handlers for the given name, including handlers
    created via the ``@workflow.query`` decorator.

    Args:
        name: Name of the query.
        handler: Callable to set or None to unset.
    Nr   r   r.  r  rG   rG   rI   set_query_handler?  s   
r  c                   C  r  )zGet the dynamic query handler if any.

    This includes dynamic handlers created via the ``@workflow.query``
    decorator.

    Returns:
        Callable for the dynamic query handler if any.
    Nr  rG   rG   rG   rI   get_dynamic_query_handlerL  r  r  c                 C  r	  )zSet or unset the dynamic query handler.

    This overrides the existing dynamic handler even if it was created via the
    ``@workflow.query`` decorator.

    Args:
        handler: Callable to set or None to unset.
    Nr  r
  rG   rG   rI   set_dynamic_query_handlerX  s   	r  c                 C  r  )aT  Get the update handler for the given name if any.

    This includes handlers created via the ``@workflow.update`` decorator.

    Args:
        name: Name of the update.

    Returns:
        Callable for the update if any. If a handler is not found for the name,
        this will not return the dynamic handler even if there is one.
    r   r   r  rF  rG   rG   rI   get_update_handlerd  r  r  )r0  r0  c                C  s   t  | || dS )aj  Set or unset the update handler for the given name.

    This overrides any existing handlers for the given name, including handlers
    created via the ``@workflow.update`` decorator.

    Args:
        name: Name of the update.
        handler: Callable to set or None to unset.
        validator: Callable to set or None to unset as the update validator.
    Nr   r   r1  )rM   r,  r0  rG   rG   rI   set_update_handlers  s   r  c                   C  r  )zGet the dynamic update handler if any.

    This includes dynamic handlers created via the ``@workflow.update``
    decorator.

    Returns:
        Callable for the dynamic update handler if any.
    Nr  rG   rG   rG   rI   get_dynamic_update_handler  r  r  c                C  s   t  d| | dS )a,  Set or unset the dynamic update handler.

    This overrides the existing dynamic handler even if it was created via the
    ``@workflow.update`` decorator.

    Args:
        handler: Callable to set or None to unset.
        validator: Callable to set or None to unset as the update validator.
    Nr  )r,  r0  rG   rG   rI   set_dynamic_update_handler  s   r  c                   C  r   )a  Whether update and signal handlers have finished executing.

    Consider waiting on this condition before workflow return or continue-as-new, to prevent
    interruption of in-progress handlers by workflow exit:
    ``await workflow.wait_condition(lambda: workflow.all_handlers_finished())``

    Returns:
        True if there are no in-progress update or signal handler executions.
    )r   r   r  rG   rG   rG   rI   all_handlers_finished  r   r  )r`  fsIterable[Awaitable[AnyType]]rc  Iterator[Awaitable[AnyType]]c                #  s    t | st | rtdt| j t  t  fddt| D d fdd}fdd fd	d
}D ]}|	  qBrV|durV
||ttD ]}| V  q\dS )zReturn an iterator whose values are coroutines.

    This is a deterministic version of :py:func:`asyncio.as_completed`. This
    function should be used instead of that one in workflows.
    z#expect an iterable of futures, not c                   s   g | ]	}t j| d qS )r   )r   ensure_futurerH  fr   rG   rI   rJ    s    z as_completed.<locals>.<listcomp>Nc                    s*   D ]} |    d  q  d S rF   )remove_done_callback
put_nowaitclearr  )_on_completiondonetodorG   rI   _on_timeout  s   
z!as_completed.<locals>._on_timeoutc                   s<   sd S  |   |  sd ur  d S d S d S rF   )remover   r  r"  )r$  timeout_handler%  rG   rI   r#    s   

z$as_completed.<locals>._on_completionc                    s&      I d H } | d u rtj|  S rF   )r  r   TimeoutErrorresultr"  )r$  rG   rI   _wait_for_one  s
   z#as_completed.<locals>._wait_for_one)r   isfutureiscoroutiner(  r  r^   Queueget_event_loopr   add_done_callback
call_laterranger   )r  r`  r&  r+  r  r:  rG   )r#  r$  r   r(  r%  rI   as_completed  s"   
r3  _FT)bound)r`  return_whenIterable[_FT]r6  Tuple[List[_FT], List[_FT]]c                  rF  rF   rG   r  r`  r6  rG   rG   rI   wait  r  r:  Iterable[asyncio.Task[AnyType]]?Tuple[List[asyncio.Task[AnyType]], List[asyncio.Task[AnyType]]]c                  rF  rF   rG   r9  rG   rG   rI   r:    r  r   r   c                  s   t | st | rtdt| j | std|t jt jt j	fvr,td| t
| } tdd | D r=tdt  }t| |||I dH S )zWait for the Futures or Tasks given by fs to complete.

    This is a deterministic version of :py:func:`asyncio.wait`. This function
    should be used instead of that one in workflows.
    z)Expect an iterable of Tasks/Futures, not ,Sequence of Tasks/Futures must not be empty.zInvalid return_when value: c                 s  s    | ]}t |V  qd S rF   )r   r-  r  rG   rG   rI   	<genexpr>  s    zwait.<locals>.<genexpr>z6Passing coroutines is forbidden, use tasks explicitly.N)r   r,  r-  r(  r  r^   re   FIRST_COMPLETEDFIRST_EXCEPTIONALL_COMPLETEDr   anyr   _wait)r  r`  r6  r   rG   rG   rI   r:    s    -Iterable[Union[asyncio.Future, asyncio.Task]]r   r   Tuple[List, List]c              
     s   | sJ d|  d |d ur||tt|   fdd}| D ]}|| q'zI d H  W d ur>  | D ]}|| q@nd urQ  | D ]}|| qSw g g }}| D ]}| ro|| qc|| qc||fS )Nr=  c                   sn    d8   dkst jkst jkr/|  s1|  d ur3d ur$   s5d  d S d S d S d S d S )Nr-   r   )r   r?  r@  	cancelled	exceptionr  r$  
set_resultr"  counterr6  r(  waiterrG   rI   r#  )  s   

z_wait.<locals>._on_completion)	create_futurer1  _release_waiterr   r0  r  r  r$  r,  )r  r`  r6  r   r#  r  r$  pendingrG   rI  rI   rC    s8   

rC  rK  asyncio.Future[Any]c                 G  s   |   s| d  d S d S rF   )r$  rH  )rK  r  rG   rG   rI   rM  K  s   rM  r    c                 C  s6   t | ot | t |u o| jddd |jkS )N.r-   r   )rj   r/  	getmodulerl   rsplitr^   )rh   rC   rG   rG   rI   r+  S  s
   
r+  c                      s   e Zd Zd	 fddZ  ZS )
_UnexpectedEvictionErrorreasonTtemporalio.bridge.proto.workflow_activation.RemoveFromCache.EvictionReason.ValueTypemessager   rD   r   c                   s8   t jjjjj|| _|| _t	 
| j d|  d S )Nz: )r   rq  rr  workflow_activationRemoveFromCacheEvictionReasonNamerT  rV  r  rc   )r   rT  rV  r  rG   rI   rc   ]  s
   z!_UnexpectedEvictionError.__init__)rT  rU  rV  r   rD   r   r^   rq   rl   rc   r  rG   rG   r  rI   rS  \      rS  c                      r  )	NondeterminismErrorzFError that can be thrown during replay for non-deterministic workflow.rV  r   rD   r   c                      t  | || _dS )z"Initialize a nondeterminism error.Nr  rc   rV  r   rV  r  rG   rI   rc   l     
zNondeterminismError.__init__rV  r   rD   r   r  rG   rG   r  rI   r]  i  s    r]  c                      r  )	ReadOnlyContextErrorzwError thrown when trying to do mutable workflow calls in a read-only
    context like a query or update validator.
    rV  r   rD   r   c                   r^  )z%Initialize a read-only context error.Nr_  r`  r  rG   rI   rc   w  ra  zReadOnlyContextError.__init__rb  r  rG   rG   r  rI   rc  r  s    rc  c                      s   e Zd Zd fddZ  ZS )r   r  r>  rD   r   c                   s   t  d d| _d S r   r_  r  r  rG   rI   rc   ~  s   
z%_NotInWorkflowEventLoopError.__init__r  r[  rG   rG   r  rI   r   }  r\  r   c                   @  s"   e Zd ZdZdZdZd	ddZdS )
VersioningIntenta  Indicates whether the user intends certain commands to be run on a compatible worker Build
    Id version or not.

    `COMPATIBLE` indicates that the command should run on a worker with compatible version if
    possible. It may not be possible if the target task queue does not also have knowledge of the
    current worker's Build Id.

    `DEFAULT` indicates that the command should run on the target task queue's current
    overall-default Build Id.

    Where this type is accepted optionally, an unset value indicates that the SDK should choose the
    most sensible default behavior for the type of command, accounting for whether the command will
    be run on the same task queue as the current worker.

    .. deprecated::
        Use Worker Deployment versioning instead.
    r-   rp   rD   9temporalio.bridge.proto.common.VersioningIntent.ValueTypec                 C  s>   | t jkrtjjjj jS | t jkrtjjjj jS tjjjj jS rF   )rd  
COMPATIBLEr   rq  rr  r   DEFAULTr   r   rG   rG   rI   	_to_proto  s
   

zVersioningIntent._to_protoN)rD   re  )r^   rq   rl   rr   rf  rg  rh  rG   rG   rG   rI   rd    s
    rd  ServiceTc                   @  s^   e Zd ZdZeejjjj	j
Z
	 eejjjj	jZ	 eejjjj	jZ	 eejjjj	jZdS )NexusOperationCancellationTypea  Defines behavior of a Nexus operation when the caller workflow initiates cancellation.

    Pass one of these values to :py:meth:`NexusClient.start_operation` to define cancellation
    behavior.

    To initiate cancellation, use :py:meth:`NexusOperationHandle.cancel` and then `await` the
    operation handle. This will result in a :py:class:`exceptions.NexusOperationError`. The values
    of this enum define what is guaranteed to have happened by that point.
    N)r^   rq   rl   rr   r   r   rq  rr  nexusrj  rt   rt  r  WAIT_REQUESTEDru  WAIT_COMPLETEDrG   rG   rG   rI   rj    s     
rj  c                   @  s  e Zd ZdZeeddejddd(ddZeeddejddd)ddZeeddejddd*ddZeeddejddd+ddZeeddejddd,ddZeddejddd-ddZeeddejddd.dd Z	eeddejddd/d!d Z	eeddejddd0d"d Z	eeddejddd1d$d Z	eeddejddd2d&d Z	eddejddd-d'd Z	dS )3NexusClienta  A client for invoking Nexus operations.

    .. warning::
        This API is experimental and unstable.

    Example::

        nexus_client = workflow.create_nexus_client(
            endpoint=my_nexus_endpoint,
            service=MyService,
        )
        handle = await nexus_client.start_operation(
            operation=MyService.my_operation,
            input=MyOperationInput(value="hello"),
            schedule_to_close_timeout=timedelta(seconds=10),
        )
        result = await handle.result()
    NrP  r5  r9  r   rM  #nexusrpc.Operation[InputT, OutputT]rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   rT  c                  rF  rF   rG   r   rM  rO  rP  r5  r9  r   rG   rG   rI   start_operation  rV  zNexusClient.start_operationr   r   c                  rF  rF   rG   rq  rG   rG   rI   rr    rV  Callable[[ServiceHandlerT, temporalio.nexus.WorkflowRunOperationContext, InputT], Awaitable[temporalio.nexus.WorkflowHandle[OutputT]]]c                  rF  rF   rG   rq  rG   rG   rI   rr       _Callable[[ServiceHandlerT, nexusrpc.handler.StartOperationContext, InputT], Awaitable[OutputT]]c                  rF  rF   rG   rq  rG   rG   rI   rr    rt  TCallable[[ServiceHandlerT, nexusrpc.handler.StartOperationContext, InputT], OutputT]c                  rF  rF   rG   rq  rG   rG   rI   rr    rt  c                     dS )a  Start a Nexus operation and return its handle.

        Args:
            operation: The Nexus operation.
            input: The Nexus operation input.
            output_type: The Nexus operation output type.
            schedule_to_close_timeout: Timeout for the entire operation attempt.
            headers: Headers to send with the Nexus HTTP request.

        Returns:
            A handle to the Nexus operation. The result can be obtained as
            ```python
            await handle.result()
            ```
        NrG   rq  rG   rG   rI   rr  ,  s   r&   c                  rF  rF   rG   rq  rG   rG   rI   execute_operationI  rV  zNexusClient.execute_operationc                  rF  rF   rG   rq  rG   rG   rI   rx  W  rV  c                  rF  rF   rG   rq  rG   rG   rI   rx  e  rt  XCallable[[ServiceT, nexusrpc.handler.StartOperationContext, InputT], Awaitable[OutputT]]c                  rF  rF   rG   rq  rG   rG   rI   rx  y  rt  MCallable[[ServiceT, nexusrpc.handler.StartOperationContext, InputT], OutputT]c                  rF  rF   rG   rq  rG   rG   rI   rx    rt  c                  rw  )a  Execute a Nexus operation and return its result.

        Args:
            operation: The Nexus operation.
            input: The Nexus operation input.
            output_type: The Nexus operation output type.
            schedule_to_close_timeout: Timeout for the entire operation attempt.
            headers: Headers to send with the Nexus HTTP request.

        Returns:
            The operation result.
        NrG   rq  rG   rG   rI   rx    s   )rM  rp  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   rT  )rM  r   rO  r   rP  rQ  r5  r   r9  rj  r   rS  rD   rT  )rM  rs  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   rT  )rM  ru  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   rT  )rM  rv  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   rT  )rM  r   rO  r   rP  rQ  r5  r   r9  rj  r   rS  rD   r   )rM  rp  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   r&   )rM  r   rO  r   rP  rQ  r5  r   r9  rj  r   rS  rD   r&   )rM  rs  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   r&   )rM  ry  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   r&   )rM  rz  rO  r%   rP  rQ  r5  r   r9  rj  r   rS  rD   r&   )
r^   rq   rl   rr   r$   r   rj  rm  rr  rx  rG   rG   rG   rI   rn    s    						rn  c                   @  sF   e Zd ZdddZd	d	ejd	d
dddZd	d	ejd	d
dddZd	S )_NexusClientrK  r   rL  Union[Type[ServiceT], str]rD   r   c                C  sF   t |tr	|| _nt| }r|j| _n	tdt| || _dS )zCreate a Nexus client.

        Args:
            service: The Nexus service.
            endpoint: The Nexus endpoint.
        z`service` may be a name (str), or a class decorated with either @nexusrpc.handler.service_handler or @nexusrpc.service. Invalid service type: N)	r  r   service_namenexusrpcget_service_definitionrM   re   r  rK  )r   rK  rL  service_defnrG   rG   rI   rc     s   


z_NexusClient.__init__Nro  rM  r   rO  rP  r!  r5  r   r9  rj  r   rS  c             
     s.   t jj j| j| j||||||dI d H S )N)rK  rL  rM  rO  rP  r5  r9  r   )r   r  r   r   rU  rK  r}  rq  rG   rG   rI   rr    s   
z_NexusClient.start_operationc                  s(   | j ||||||dI d H }|I d H S )Nro  )rr  )r   rM  rO  rP  r5  r9  r   r  rG   rG   rI   rx    s   

z_NexusClient.execute_operation)rK  r   rL  r|  rD   r   )rM  r   rO  r   rP  r!  r5  r   r9  rj  r   rS  rD   r   )r^   rq   rl   rc   rj  rm  rr  rx  rG   rG   rG   rI   r{    s    
r{  rL  Type[ServiceT]rK  NexusClient[ServiceT]c                 C  rE   rF   rG   rL  rK  rG   rG   rI   create_nexus_client     r  NexusClient[Any]c                 C  rE   rF   rG   r  rG   rG   rI   r    r  r|  c                 C  s   t || dS )zCreate a Nexus client.

    .. warning::
        This API is experimental and unstable.

    Args:
        service: The Nexus service.
        endpoint: The Nexus endpoint.
    )rK  rL  )r{  r  rG   rG   rI   r    s   ra   )
rM   rQ   rN   rR   rO   rS   rP   rT   rD   rU   )rN   rR   rX   rR   rP   rT   rD   rU   rF   )rC   rZ   rM   rQ   rN   rR   rX   rR   rO   rS   rP   rT   )rb   r6   rD   r6   )rh   r1   rD   r1   )rh   r3   rD   r3   )r}   ro   r~   rQ   rD   r   )rM   r   r}   ro   r~   rQ   rD   r   )rX   r   r}   ro   r~   rQ   rD   r   )
rh   r   rM   rQ   rX   r   r}   ro   r~   rQ   )rh   r6   rD   r6   )rM   r   r~   rQ   rD   r   )rX   r   r~   rQ   rD   r   )r~   r   rD   r   )rh   r   rM   rQ   rX   r   r~   rQ   )rh   r   rD   r   )r  r   rD   r   )rD   r  )r   r   rD   r   rr  rs  rt  r   r   r{  )r  r   r  r   rD   r   )r  r   r   r  rD   r?   )r  r   r  r.   r   r  rD   r  ru  rv  r   )rD   rm  )r   r  rD   r  r|  r}  )r~   r   rD   r   rw  )rD   r   )r   r   rD   rR   rx  ry  )rD   r]  r   rz  )rh   r  rD   r  )rh   r  rD   r  )r}   ro   r~   rQ   rD   r  )rM   r   r}   ro   r~   rQ   rD   r  )rX   r   r}   ro   r~   rQ   rD   r  )
rh   r  rM   rQ   rX   r   r}   ro   r~   rQ   )r  r  rh   r  rD   r  )rD   r  )r\  r  r2  rQ   rD   r   )rh   rb  r`  r  ra  rQ   rD   r   )rB  r   rC  r   rD   rR   )rK  r   rh   rL  rD   rL  )rh   r   r  r  r   rR   rD   rR   )r3  rx  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r}  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r~  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  ) r3  r   r  r   r  r  r   rQ   r4  r  r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r<  ) r3  r   r  r   r  r  r   rQ   r4  r  r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r<  )r3  rx  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r}  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r~  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   ) r3  r   r  r   r  r  r   rQ   r4  r  r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r   ) r3  r   r  r   r  r  r   rQ   r4  r  r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r   )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r   r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r<  )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r   r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r   )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   ry  )r3  r   r  r   r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r<  )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r?   r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r  r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   rA   )r3  r   r  r   r  r  r   rQ   r5  r   r6  r   r7  r   r8  r   r   r   r9  r:  r;  rQ   r  r  r2  rQ   r   r   rD   r   )r3  rx  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r}  r;  rQ   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r2  rQ   rD   ry  )r3  r~  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r   r  r   r  r  r4  r!  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r<  )r3  r   r  r   r  r  r4  r!  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r<  )r3  rx  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r}  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r~  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r   r  r   r  r  r4  r!  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r   )r3  r   r  r   r  r  r4  r!  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r   )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   rD   ry  )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   rD   ry  )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   rD   ry  )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   rD   ry  )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   rD   ry  )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   rD   ry  )r3  r  r  r   r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r<  )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r   r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r   )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   ry  )r3  r   r  r   r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r<  )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r?   r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r  r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   rA   )r3  r   r  r   r  r  r5  r   r6  r   r7  r   r   r   rI  r   r9  r:  r;  rQ   r2  rQ   rD   r   )$r  r  r   rQ   r   rQ   r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   r  )&r  r  r  r?   r   rQ   r   rQ   r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   r  )&r  r  r  r  r   rQ   r   rQ   r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   r  )*r  r   r  r   r  r  r   rQ   r   rQ   r4  r!  r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   rE  )*r  r   r  r   r  r  r   rQ   r   rQ   r4  r!  r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   rE  )$r  r  r   rQ   r   rQ   r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   rA   )&r  r  r  r?   r   rQ   r   rQ   r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   rA   )&r  r  r  r  r   rQ   r   rQ   r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   rA   )*r  r   r  r   r  r  r   rQ   r   rQ   r4  r!  r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   r   )*r  r   r  r   r  r  r   rQ   r   rQ   r4  r!  r9  r@  rA  rB  r   r   r   r   r   r   rC  rD  r   r   r   r   r
  r  r   r  r  r  r>  rQ   r?  rQ   r   r   rD   r   )r   r   r   rQ   rD   r  )r  r  r   r   r   rQ   rD   r  )r  r   r  r  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   )r  r  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   )r  r?   r  r  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   )r  r  r  r  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   )r  r   r  r  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   )r  r   r  r  r  r	  r   rQ   r   r   r   r   r   r   r
  r  r   r  r  r  rD   r   )rM   r   rD   r  )rM   r   r,  r  rD   r   )rD   r  )r,  r  rD   r   )rM   r   r,  r  r0  r  rD   r   )r,  r  r0  r  rD   r   )r  r  r`  rc  rD   r  )r  r7  r`  rc  r6  r   rD   r8  )r  r;  r`  rc  r6  r   rD   r<  )r  r   r`  rc  r6  r   rD   r   )
r  rD  r`  rc  r6  r   r   r   rD   rE  )rK  rO  rD   r   )rh   rL  rC   r    rD   rR   )rL  r  rK  r   rD   r  )rL  r   rK  r   rD   r  )rL  r|  rK  r   rD   r  )rr   
__future__r   r   contextvarsrj   logging	threadingr  r   abcr   r   
contextlibr   dataclassesr   r   r   r	   enumr
   r   r   r   	functoolsr   r  r   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r~  nexusrpc.handlerr%   r&   typing_extensionsr'   r(   r)   r*   r+   temporalio.api.common.v1r   &temporalio.bridge.proto.child_workflow)temporalio.bridge.proto.workflow_commandstemporalio.commontemporalio.convertertemporalio.exceptionstemporalio.nexustemporalio.workflowtemporalio.nexus._utilr,   typesr.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rJ   r   r   r   rg   rn   ro   RuntimeWarningrv   ry   rz   rs   r   r   r   r   r   r   r   r   
ContextVarr  r   r  r  r  r  r  r  r  r
  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  localr  r  r  r  r  r  r  	getLoggerr^   r  r\   r-  rP  rY  r   r   r  Taskrm  rp  r:  rv  rt  r  r  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r@  rB  r  ru  r  WorkflowIDReusePolicyALLOW_DUPLICATEr  r  r  r  r  r  rj  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r3  Futurer4  rA  r:  rC  rM  r+  
exceptionsTemporalErrorrS  r]  rc  r   rd  ri  rj  rn  r{  r  rG   rG   rG   rI   <module>   sL   \\		1	
?G}  
					

C	tQ s2"9
M+((()>%"$"$#D\:D<2#3		
% lG