Movatterモバイル変換


[0]ホーム

URL:


temporalio.workflow

module documentation
(source)

Utilities that can decorate or be called inside workflows.

ClassActivityCancellationTypeHow an activity cancellation should be handled.
ClassActivityConfigTypedDict of config that can be used forstart_activity andexecute_activity.
ClassActivityHandleHandle returned fromstart_activity andstart_local_activity.
ClassChildWorkflowCancellationTypeHow a child workflow cancellation should be handled.
ClassChildWorkflowConfigTypedDict of config that can be used forstart_child_workflow andexecute_child_workflow.
ClassChildWorkflowHandleHandle for interacting with a child workflow.
ClassDynamicWorkflowConfigReturned by functions using thedynamic_config decorator, see it for more.
ClassExternalWorkflowHandleHandle for interacting with an external workflow.
ClassHandlerUnfinishedPolicyActions taken if a workflow terminates with running handlers.
ClassInfoInformation about the running workflow.
ClassLocalActivityConfigTypedDict of config that can be used forstart_local_activity andexecute_local_activity.
ClassLoggerAdapterAdapter that adds details to the log about the running workflow.
ClassNexusClientA client for invoking Nexus operations.
ClassNexusOperationCancellationTypeDefines behavior of a Nexus operation when the caller workflow initiates cancellation.
ClassNexusOperationHandleHandle for interacting with a Nexus operation.
ClassParentClosePolicyHow a child workflow should be handled when the parent closes.
ClassParentInfoInformation about the parent workflow.
ClassRootInfoInformation about the root workflow.
ClassunsafeContains static methods that should not normally be called during workflow execution except in advanced cases.
ClassUpdateInfoInformation about a workflow update.
ClassUpdateMethodMultiParamDecorated workflow update functions implement this.
ClassVersioningIntentIndicates whether the user intends certain commands to be run on a compatible worker Build Id version or not.
ExceptionContinueAsNewErrorError thrown bycontinue_as_new.
ExceptionNondeterminismErrorError that can be thrown during replay for non-deterministic workflow.
ExceptionReadOnlyContextErrorError thrown when trying to do mutable workflow calls in a read-only context like a query or update validator.
ExceptionUnfinishedSignalHandlersWarningThe workflow exited before all signal handlers had finished executing.
ExceptionUnfinishedUpdateHandlersWarningThe workflow exited before all update handlers had finished executing.
Functionall_handlers_finishedWhether update and signal handlers have finished executing.
Functionas_completedReturn an iterator whose values are coroutines.
Functioncontinue_as_newStop the workflow immediately and continue as new.
Functioncreate_nexus_clientCreate a Nexus client.
Functioncurrent_update_infoInfo for the current update if any.
FunctiondefnDecorator for workflow classes.
Functiondeprecate_patchMark a patch as deprecated.
Functiondynamic_configDecorator to allow configuring a dynamic workflow's behavior.
Async Functionexecute_activityStart an activity and wait for completion.
Async Functionexecute_activity_classStart an activity from a callable class and wait for completion.
Async Functionexecute_activity_methodStart an activity from a method and wait for completion.
Async Functionexecute_child_workflowStart a child workflow and wait for completion.
Async Functionexecute_local_activityStart a local activity and wait for completion.
Async Functionexecute_local_activity_classStart a local activity from a callable class and wait for completion.
Async Functionexecute_local_activity_methodStart a local activity from a method and wait for completion.
Functionextern_functionsExternal functions available in the workflow sandbox.
Functionget_current_detailsGet 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...
Functionget_dynamic_query_handlerGet the dynamic query handler if any.
Functionget_dynamic_signal_handlerGet the dynamic signal handler if any.
Functionget_dynamic_update_handlerGet the dynamic update handler if any.
Functionget_external_workflow_handleGet a workflow handle to an existing workflow by its ID.
Functionget_external_workflow_handle_forGet a typed workflow handle to an existing workflow by its ID.
Functionget_last_completion_resultGet 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.
Functionget_last_failureGet the last failure of the workflow if it has run previously.
Functionget_query_handlerGet the query handler for the given name if any.
Functionget_signal_handlerGet the signal handler for the given name if any.
Functionget_update_handlerGet the update handler for the given name if any.
Functionhas_last_completion_resultGets whether there is a last completion result of the workflow.
Functionin_workflowWhether the code is currently running in a workflow.
FunctioninfoCurrent workflow's info.
FunctioninitDecorator for the workflow init method.
FunctioninstanceCurrent workflow's instance.
Functionis_failure_exceptionChecks if the given exception is a workflow failure in the current workflow.
FunctionmemoCurrent workflow's memo values, converted without type hints.
Functionmemo_valueMemo value for the given key, optional default, and optional type hint.
Functionmetric_meterGet the metric meter for the current workflow.
FunctionnowCurrent time from the workflow perspective.
FunctionpatchedPatch a workflow.
Functionpayload_converterGet the payload converter for the current workflow.
FunctionqueryDecorator for a workflow query method.
FunctionrandomGet a deterministic pseudo-random number generator.
FunctionrunDecorator for the workflow run method.
Functionset_current_detailsSet 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...
Functionset_dynamic_query_handlerSet or unset the dynamic query handler.
Functionset_dynamic_signal_handlerSet or unset the dynamic signal handler.
Functionset_dynamic_update_handlerSet or unset the dynamic update handler.
Functionset_query_handlerSet or unset the query handler for the given name.
Functionset_signal_handlerSet or unset the signal handler for the given name.
Functionset_update_handlerSet or unset the update handler for the given name.
FunctionsignalDecorator for a workflow signal method.
Async FunctionsleepSleep for the given duration.
Functionstart_activityStart an activity and return its handle.
Functionstart_activity_classStart an activity from a callable class.
Functionstart_activity_methodStart an activity from a method.
Async Functionstart_child_workflowStart a child workflow and return its handle.
Functionstart_local_activityStart a local activity and return its handle.
Functionstart_local_activity_classStart a local activity from a callable class.
Functionstart_local_activity_methodStart a local activity from a method.
FunctiontimeCurrent seconds since the epoch from the workflow perspective.
Functiontime_nsCurrent nanoseconds since the epoch from the workflow perspective.
FunctionupdateDecorator for a workflow update handler method.
Functionupsert_memoAdds, modifies, and/or removes memos, with upsert semantics.
Functionupsert_search_attributesUpsert search attributes for this workflow.
Functionuuid4Get a new, determinism-safe v4 UUID based onrandom.
Async FunctionwaitWait for the Futures or Tasks given by fs to complete.
Async Functionwait_conditionWait on a callback to become true.
Type VariableServiceTUndocumented
VariableloggerLogger that will have contextual workflow details embedded.
Class_AsyncioTaskUndocumented
Class_DefinitionUndocumented
Class_NexusClientNo class docstring; 0/2 instance variable, 1/3 method documented
Class_QueryDefinitionUndocumented
Class_RuntimeUndocumented
Class_SignalDefinitionUndocumented
Class_UpdateDefinitionUndocumented
Exception_NotInWorkflowEventLoopErrorUndocumented
Exception_UnexpectedEvictionErrorUndocumented
Function_assert_dynamic_handler_argsUndocumented
Function_bind_methodUndocumented
Function_is_unbound_method_on_clsUndocumented
Function_parameters_identical_up_to_namingReturn True if the functions have identical parameter lists, ignoring parameter names.
Function_release_waiterUndocumented
Function_set_current_update_infoUndocumented
Function_update_validatorDecorator for a workflow update validator method.
Async Function_waitUndocumented
Type Variable_FTUndocumented
Variable_current_update_infoUndocumented
Variable_imports_passed_throughUndocumented
Variable_in_sandboxUndocumented
Variable_sandbox_unrestrictedUndocumented
defall_handlers_finished() ->bool: (source)

Whether update and signal handlers have finished executing.

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

Returns
boolTrue if there are no in-progress update or signal handler executions.
defas_completed(fs:Iterable[Awaitable[AnyType]], *, timeout:float |None =None) ->Iterator[Awaitable[AnyType]]: (source)

Return an iterator whose values are coroutines.

This is a deterministic version ofasyncio.as_completed. Thisfunction should be used instead of that one in workflows.

@overload
defcontinue_as_new(arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], task_queue:str |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None) ->NoReturn:
@overload
defcontinue_as_new(*, workflow:MethodAsyncNoParam[SelfType,Any], task_queue:str |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None) ->NoReturn:
@overload
defcontinue_as_new(arg:ParamType, *, workflow:MethodAsyncSingleParam[SelfType,ParamType,Any], task_queue:str |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None) ->NoReturn:
@overload
defcontinue_as_new(*, workflow:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[Any]], args:Sequence[Any], task_queue:str |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None) ->NoReturn:
@overload
defcontinue_as_new(*, workflow:str, args:Sequence[Any] = [], task_queue:str |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None) ->NoReturn:
(source)

Stop the workflow immediately and continue as new.

Parameters
arg:AnySingle argument to the continued workflow.
args:Sequence[Any]Multiple arguments to the continued workflow. Cannot be set if argis.
workflow:None |Callable |strSpecific workflow to continue to. Defaults to the currentworkflow.
task_queue:str |NoneTask queue to run the workflow on. Defaults to the currentworkflow's task queue.
run_timeout:timedelta |NoneTimeout of a single workflow run. Defaults to the currentworkflow's run timeout.
task_timeout:timedelta |NoneTimeout of a single workflow task. Defaults to the currentworkflow's task timeout.
retry_policy:temporalio.common.RetryPolicy |NoneUndocumented
memo:Mapping[str,Any] |NoneMemo for the workflow. Defaults to the current workflow's memo.
search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |NoneSearch attributes for the workflow. Defaults to thecurrent workflow's search attributes. The dictionary form of this isDEPRECATED.
versioning_intent:VersioningIntent |NoneWhen using the Worker Versioning feature, specifies whether this Workflowshould Continue-as-New onto a worker with a compatible Build Id or not.Deprecated: Use Worker Deployment versioning instead.
Returns
NoReturnNever returns, always raises aContinueAsNewError.
Raises
ContinueAsNewErrorAlways raised by this function. Should not be caughtbut instead be allowed to
@overload
defcreate_nexus_client(*, service:type[ServiceT], endpoint:str) ->NexusClient[ServiceT]:
@overload
defcreate_nexus_client(*, service:str, endpoint:str) ->NexusClient[Any]:
(source)

Create a Nexus client.

Warning

This API is experimental and unstable.

Parameters
service:type[ServiceT] |strThe Nexus service.
endpoint:strThe Nexus endpoint.
Returns
NexusClient[ServiceT]Undocumented
defcurrent_update_info() ->UpdateInfo |None: (source)

Info for the current update if any.

This is powered bycontextvars so it is only valid within theupdate handler and coroutines/tasks it has started.

Returns
UpdateInfo |None
Info for the current update handler the code calling this is executing
within if any.
@overload
defdefn(cls:ClassType) ->ClassType:
@overload
defdefn(*, name:str |None =None, sandboxed:bool =True, failure_exception_types:Sequence[type[BaseException]] = [], versioning_behavior:temporalio.common.VersioningBehavior = temporalio.common.VersioningBehavior.UNSPECIFIED) ->Callable[[ClassType],ClassType]:
@overload
defdefn(*, sandboxed:bool =True, dynamic:bool =False, versioning_behavior:temporalio.common.VersioningBehavior = temporalio.common.VersioningBehavior.UNSPECIFIED) ->Callable[[ClassType],ClassType]:
(source)

Decorator for workflow classes.

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

Parameters
cls:ClassType |NoneThe class to decorate.
name:str |NoneName to use for the workflow. Defaults to class__name__. Thiscannot be set if dynamic is set.
sandboxed:boolWhether the workflow should run in a sandbox. Default istrue.
dynamic:boolIf true, this activity will be dynamic. Dynamic workflows haveto accept a single 'Sequence[RawValue]' parameter. This cannot beset to true if name is present.
failure_exception_types:Sequence[type[BaseException]]The types of exceptions that, if aworkflow-thrown exception extends, will cause the workflow/update tofail instead of suspending the workflow via task failure. These areapplied in addition to ones set on the worker constructor. IfException is set, it effectively will fail a workflow/update inall user exception cases. WARNING: This setting is experimental.
versioning_behavior:temporalio.common.VersioningBehaviorSpecifies the versioning behavior to use for this workflow.WARNING: This setting is experimental.
defdeprecate_patch(id:str): (source)

Mark a patch as deprecated.

This marks a workflow that hadpatched in a previous version ofthe code as no longer applicable because all workflows that use the old codepath are done and will never be queried again. Therefore the old code pathis removed as well.

Parameters
id:strThe identifier originally used withpatched.
defdynamic_config(fn:MethodSyncNoParam[SelfType,DynamicWorkflowConfig]) ->MethodSyncNoParam[SelfType,DynamicWorkflowConfig]: (source)

Decorator to allow configuring a dynamic workflow's behavior.

Because dynamic workflows may conceptually represent more than one workflow type, it may bedesirable to have different settings for fields that would normally be passed todefn, but vary based on the workflow type name or other information available inthe workflow's context. This function will be called after the workflow'sinit,if it has one, but before the workflow'srun method.

The method must only take self as a parameter, and any values set in the class it returns willoverride those provided todefn.

Cannot be specified on non-dynamic workflows.

Parameters
fn:MethodSyncNoParam[SelfType,DynamicWorkflowConfig]The function to decorate.
Returns
MethodSyncNoParam[SelfType,DynamicWorkflowConfig]Undocumented
@overload
async defexecute_activity(activity:CallableAsyncNoParam[ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity(activity:CallableSyncNoParam[ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity(activity:CallableAsyncSingleParam[ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity(activity:CallableSyncSingleParam[ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity(activity:Callable[...,Awaitable[ReturnType]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity(activity:Callable[...,ReturnType], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity(activity:str, arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], task_queue:str |None =None, result_type:type |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->Any:
(source)

Start an activity and wait for completion.

This is a shortcut forawaitstart_activity.

@overload
async defexecute_activity_class(activity:type[CallableAsyncNoParam[ReturnType]], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_class(activity:type[CallableSyncNoParam[ReturnType]], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_class(activity:type[CallableAsyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_class(activity:type[CallableSyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_class(activity:type[Callable[...,Awaitable[ReturnType]]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_class(activity:type[Callable[...,ReturnType]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
(source)

Start an activity from a callable class and wait for completion.

This is a shortcut forawaitstart_activity_class.

@overload
async defexecute_activity_method(activity:MethodAsyncNoParam[SelfType,ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_method(activity:MethodSyncNoParam[SelfType,ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_method(activity:MethodAsyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_method(activity:MethodSyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[ReturnType]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],ReturnType], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
(source)

Start an activity from a method and wait for completion.

This is a shortcut forawaitstart_activity_method.

@overload
async defexecute_child_workflow(workflow:MethodAsyncNoParam[SelfType,ReturnType], *, id:str |None =None, task_queue:str |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_child_workflow(workflow:MethodAsyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, id:str |None =None, task_queue:str |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_child_workflow(workflow:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[ReturnType]], *, args:Sequence[Any], id:str |None =None, task_queue:str |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ReturnType:
@overload
async defexecute_child_workflow(workflow:str, arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], id:str |None =None, task_queue:str |None =None, result_type:type |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->Any:
(source)

Start a child workflow and wait for completion.

This is a shortcut forawait (awaitstart_child_workflow).

@overload
async defexecute_local_activity(activity:CallableAsyncNoParam[ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity(activity:CallableSyncNoParam[ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity(activity:CallableAsyncSingleParam[ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity(activity:CallableSyncSingleParam[ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity(activity:Callable[...,Awaitable[ReturnType]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity(activity:Callable[...,ReturnType], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity(activity:str, arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], result_type:type |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->Any:
(source)

Start a local activity and wait for completion.

This is a shortcut forawaitstart_local_activity.

@overload
async defexecute_local_activity_class(activity:type[CallableAsyncNoParam[ReturnType]], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_class(activity:type[CallableSyncNoParam[ReturnType]], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_class(activity:type[CallableAsyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_class(activity:type[CallableSyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_class(activity:type[Callable[...,Awaitable[ReturnType]]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_class(activity:type[Callable[...,ReturnType]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
(source)

Start a local activity from a callable class and wait for completion.

This is a shortcut forawaitstart_local_activity_class.

@overload
async defexecute_local_activity_method(activity:MethodAsyncNoParam[SelfType,ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_method(activity:MethodSyncNoParam[SelfType,ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_method(activity:MethodAsyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_method(activity:MethodSyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[ReturnType]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
@overload
async defexecute_local_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],ReturnType], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ReturnType:
(source)

Start a local activity from a method and wait for completion.

This is a shortcut forawaitstart_local_activity_method.

defextern_functions() ->Mapping[str,Callable]: (source)

External functions available in the workflow sandbox.

Returns
Mapping[str,Callable]Mapping of external functions that can be called from inside a workflowsandbox.
defget_current_details() ->str: (source)

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 throughoutthe life of the workflow and is independent of the static details.This can be in Temporal markdown format and can span multiple lines.

defget_dynamic_query_handler() ->Callable |None: (source)

Get the dynamic query handler if any.

This includes dynamic handlers created via the@workflow.querydecorator.

Returns
Callable |NoneCallable for the dynamic query handler if any.
defget_dynamic_signal_handler() ->Callable |None: (source)

Get the dynamic signal handler if any.

This includes dynamic handlers created via the@workflow.signaldecorator.

Returns
Callable |NoneCallable for the dynamic signal handler if any.
defget_dynamic_update_handler() ->Callable |None: (source)

Get the dynamic update handler if any.

This includes dynamic handlers created via the@workflow.updatedecorator.

Returns
Callable |NoneCallable for the dynamic update handler if any.
defget_external_workflow_handle(workflow_id:str, *, run_id:str |None =None) ->ExternalWorkflowHandle[Any]: (source)

Get a workflow handle to an existing workflow by its ID.

Parameters
workflow_id:strWorkflow ID to get a handle to.
run_id:str |NoneOptional run ID for the workflow.
Returns
ExternalWorkflowHandle[Any]The external workflow handle.
defget_external_workflow_handle_for(workflow:MethodAsyncNoParam[SelfType,Any] |MethodAsyncSingleParam[SelfType,Any,Any], workflow_id:str, *, run_id:str |None =None) ->ExternalWorkflowHandle[SelfType]: (source)

Get a typed workflow handle to an existing workflow by its ID.

This is the same asget_external_workflow_handle but typed. Note,the workflow type given is not validated, it is only for typing.

Parameters
workflow:MethodAsyncNoParam[SelfType,Any] |MethodAsyncSingleParam[SelfType,Any,Any]The workflow run method to use for typing the handle.
workflow_id:strWorkflow ID to get a handle to.
run_id:str |NoneOptional run ID for the workflow.
Returns
ExternalWorkflowHandle[SelfType]The external workflow handle.
@overload
defget_last_completion_result() ->Any |None:
@overload
defget_last_completion_result(type_hint:type[ParamType]) ->ParamType |None:
(source)

Get the result of the last run of the workflow. This will be None if there wasno previous completion or the result was None. has_last_completion_result()can be used to differentiate.

defget_last_failure() ->BaseException |None: (source)

Get the last failure of the workflow if it has run previously.

defget_query_handler(name:str) ->Callable |None: (source)

Get the query handler for the given name if any.

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

Parameters
name:strName of the query.
Returns
Callable |NoneCallable 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.
defget_signal_handler(name:str) ->Callable |None: (source)

Get the signal handler for the given name if any.

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

Parameters
name:strName of the signal.
Returns
Callable |NoneCallable 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.
defget_update_handler(name:str) ->Callable |None: (source)

Get the update handler for the given name if any.

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

Parameters
name:strName of the update.
Returns
Callable |NoneCallable 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.
defhas_last_completion_result() ->bool: (source)

Gets whether there is a last completion result of the workflow.

defin_workflow() ->bool: (source)

Whether the code is currently running in a workflow.

definfo() ->Info: (source)

Current workflow's info.

Returns
InfoInfo for the currently running workflow.
definit(init_fn:CallableType) ->CallableType: (source)

Decorator for the workflow init method.

This may be used on the __init__ method of the workflow class to specifythat it accepts the same workflow input arguments as the@workflow.runmethod. If used, the parameters of your __init__ and@workflow.runmethods must be identical.

Parameters
init_fn:CallableTypeThe __init__ method to decorate.
Returns
CallableTypeUndocumented
definstance() ->Any: (source)

Current workflow's instance.

Returns
AnyThe currently running workflow instance.
defis_failure_exception(err:BaseException) ->bool: (source)

Checks if the given exception is a workflow failure in the current workflow.

Returns
boolTrue if the given exception is a workflow failure in the current workflow.
defmemo() ->Mapping[str,Any]: (source)

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 valuewill be a dict. To convert using proper type hints, usememo_value.

Returns
Mapping[str,Any]Mapping of all memo keys and they values without type hints.
@overload
defmemo_value(key:str, default:Any =temporalio.common._arg_unset) ->Any:
@overload
defmemo_value(key:str, *, type_hint:type[ParamType]) ->ParamType:
@overload
defmemo_value(key:str, default:AnyType, *, type_hint:type[ParamType]) ->AnyType |ParamType:
(source)

Memo value for the given key, optional default, and optional typehint.

Parameters
key:strKey to get memo value for.
default:AnyDefault to use if key is not present. If unset, aKeyError is raised when the key does not exist.
type_hint:type |NoneType hint to use when converting.
Returns
AnyMemo value, converted with the type hint if present.
Raises
KeyErrorKey not present and default not set.
defmetric_meter() ->temporalio.common.MetricMeter: (source)

Get the metric meter for the current workflow.

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

Returns
temporalio.common.MetricMeterCurrent metric meter for this workflow for recording metrics.
defnow() ->datetime: (source)

Current time from the workflow perspective.

This is the workflow equivalent ofdatetime.now with thetimezone.utc parameter.

Returns
datetimeUTC datetime for the current workflow time. The datetime does have UTCset as the time zone.
defpatched(id:str) ->bool: (source)

Patch a workflow.

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

Usedeprecate_patch when all workflows are done and will never bequeried again. The old code path can be used at that time too.

Parameters
id:strThe identifier for this patch. This identifier may be usedrepeatedly in the same workflow to represent the same patch
Returns
boolTrue if this should take the newer path, false if it should take theolder path.
defpayload_converter() ->temporalio.converter.PayloadConverter: (source)

Get the payload converter for the current workflow.

The returned converter hastemporalio.converter.WorkflowSerializationContext set.This is often used for dynamic workflows/signals/queries to convertpayloads.

@overload
defquery(fn:CallableType) ->CallableType:
@overload
defquery(*, name:str, description:str |None =None) ->Callable[[CallableType],CallableType]:
@overload
defquery(*, dynamic:Literal[True], description:str |None =None) ->Callable[[CallableType],CallableType]:
@overload
defquery(*, description:str) ->Callable[[CallableType],CallableType]:
(source)

Decorator for a workflow query method.

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

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

Parameters
fn:CallableType |NoneThe function to decorate.
name:str |NoneQuery name. Defaults to method__name__. Cannot be presentwhendynamic is present.
dynamic:bool |NoneIf true, this handles all queries not otherwise handled. Theparameters of the method should be self, a string name, and aSequence[RawValue]. An older form of this accepted varargparameters which will now warn. Cannot be present whenname ispresent.
description:str |NoneA short description of the query that may appear in the UI/CLI.
defrandom() ->Random: (source)

Get a deterministic pseudo-random number generator.

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

Returns
RandomThe deterministically-seeded pseudo-random number generator.
defrun(fn:CallableAsyncType) ->CallableAsyncType: (source)

Decorator for the workflow run method.

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

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

Parameters
fn:CallableAsyncTypeThe function to decorate.
Returns
CallableAsyncTypeUndocumented
defset_current_details(description:str): (source)

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 throughoutthe life of the workflow and is independent of the static details.This can be in Temporal markdown format and can span multiple lines.

defset_dynamic_query_handler(handler:Callable |None): (source)

Set or unset the dynamic query handler.

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

Parameters
handler:Callable |NoneCallable to set or None to unset.
defset_dynamic_signal_handler(handler:Callable |None): (source)

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.

Parameters
handler:Callable |NoneCallable to set or None to unset.
defset_dynamic_update_handler(handler:Callable |None, *, validator:Callable |None =None): (source)

Set or unset the dynamic update handler.

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

Parameters
handler:Callable |NoneCallable to set or None to unset.
validator:Callable |NoneCallable to set or None to unset as the update validator.
defset_query_handler(name:str, handler:Callable |None): (source)

Set or unset the query handler for the given name.

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

Parameters
name:strName of the query.
handler:Callable |NoneCallable to set or None to unset.
defset_signal_handler(name:str, handler:Callable |None): (source)

Set or unset the signal handler for the given name.

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

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

Parameters
name:strName of the signal.
handler:Callable |NoneCallable to set or None to unset.
defset_update_handler(name:str, handler:Callable |None, *, validator:Callable |None =None): (source)

Set or unset the update handler for the given name.

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

Parameters
name:strName of the update.
handler:Callable |NoneCallable to set or None to unset.
validator:Callable |NoneCallable to set or None to unset as the update validator.
@overload
@overload
@overload
@overload
(source)

Decorator for a workflow signal method.

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

Signal methods can only have positional parameters. Best practice fornon-dynamic signal methods is to only take a single object/dataclassargument that can accept more fields later if needed. Return values fromsignal methods are ignored.

Parameters
fn:CallableSyncOrAsyncReturnNoneType |NoneThe function to decorate.
name:str |NoneSignal name. Defaults to method__name__. Cannot be presentwhendynamic is present.
dynamic:bool |NoneIf true, this handles all signals not otherwise handled. Theparameters of the method must be self, a string name, and a*args positional varargs. Cannot be present whenname ispresent.
unfinished_policy:HandlerUnfinishedPolicyActions taken if a workflow terminates witha running instance of this handler.
description:str |NoneA short description of the signal that may appear in the UI/CLI.
async defsleep(duration:float |timedelta, *, summary:str |None =None): (source)

Sleep for the given duration.

Parameters
duration:float |timedeltaDuration to sleep in seconds or as a timedelta.
summary:str |NoneA single-line fixed summary for this timer that may appear in UI/CLI.This can be in single-line Temporal markdown format.
@overload
defstart_activity(activity:CallableAsyncNoParam[ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity(activity:CallableSyncNoParam[ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity(activity:CallableAsyncSingleParam[ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity(activity:CallableSyncSingleParam[ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity(activity:Callable[...,Awaitable[ReturnType]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity(activity:Callable[...,ReturnType], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity(activity:str, arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], task_queue:str |None =None, result_type:type |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[Any]:
(source)

Start an activity and return its handle.

At least one ofschedule_to_close_timeout orstart_to_close_timeoutmust be present.

Parameters
activity:AnyActivity name or function reference.
arg:AnySingle argument to the activity.
args:Sequence[Any]Multiple arguments to the activity. Cannot be set if arg is.
task_queue:str |NoneTask queue to run the activity on. Defaults to the currentworkflow's task queue.
result_type:type |NoneFor string activities, this can set the specific resulttype hint to deserialize into.
schedule_to_close_timeout:timedelta |NoneMax amount of time the activity can take fromfirst being scheduled to being completed before it times out. Thisis inclusive of all retries.
schedule_to_start_timeout:timedelta |NoneMax amount of time the activity can take tobe started from first being scheduled.
start_to_close_timeout:timedelta |NoneMax amount of time a single activity run cantake from when it starts to when it completes. This is per retry.
heartbeat_timeout:timedelta |NoneHow frequently an activity must invoke heartbeatwhile running before it is considered timed out.
retry_policy:temporalio.common.RetryPolicy |NoneHow an activity is retried on failure. If unset, aserver-defined default is used. Set maximum attempts to 1 to disableretries.
cancellation_type:ActivityCancellationTypeHow the activity is treated when it is cancelled fromthe workflow.
activity_id:str |NoneOptional unique identifier for the activity. This is anadvanced setting that should not be set unless users are sure theyneed to. Contact Temporal before setting this value.
versioning_intent:VersioningIntent |NoneWhen using the Worker Versioning feature, specifies whether this Activityshould run on a worker with a compatible Build Id or not.Deprecated: Use Worker Deployment versioning instead.
summary:str |NoneA single-line fixed summary for this activity that may appear in UI/CLI.This can be in single-line Temporal markdown format.
priority:temporalio.common.PriorityPriority of the activity.
Returns
ActivityHandle[Any]An activity handle to the activity which is an async task.
@overload
defstart_activity_class(activity:type[CallableAsyncNoParam[ReturnType]], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_class(activity:type[CallableSyncNoParam[ReturnType]], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_class(activity:type[CallableAsyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_class(activity:type[CallableSyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_class(activity:type[Callable[...,Awaitable[ReturnType]]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_class(activity:type[Callable[...,ReturnType]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
(source)

Start an activity from a callable class.

Seestart_activity for parameter and return details.

@overload
defstart_activity_method(activity:MethodAsyncNoParam[SelfType,ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_method(activity:MethodSyncNoParam[SelfType,ReturnType], *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_method(activity:MethodAsyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_method(activity:MethodSyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[ReturnType]], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
@overload
defstart_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],ReturnType], *, args:Sequence[Any], task_queue:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, heartbeat_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, versioning_intent:VersioningIntent |None =None, summary:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ActivityHandle[ReturnType]:
(source)

Start an activity from a method.

Seestart_activity for parameter and return details.

@overload
async defstart_child_workflow(workflow:MethodAsyncNoParam[SelfType,ReturnType], *, id:str |None =None, task_queue:str |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ChildWorkflowHandle[SelfType,ReturnType]:
@overload
async defstart_child_workflow(workflow:MethodAsyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, id:str |None =None, task_queue:str |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ChildWorkflowHandle[SelfType,ReturnType]:
@overload
async defstart_child_workflow(workflow:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[ReturnType]], *, args:Sequence[Any], id:str |None =None, task_queue:str |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ChildWorkflowHandle[SelfType,ReturnType]:
@overload
async defstart_child_workflow(workflow:str, arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], id:str |None =None, task_queue:str |None =None, result_type:type |None =None, cancellation_type:ChildWorkflowCancellationType =ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED, parent_close_policy:ParentClosePolicy =ParentClosePolicy.TERMINATE, execution_timeout:timedelta |None =None, run_timeout:timedelta |None =None, task_timeout:timedelta |None =None, id_reuse_policy:temporalio.common.WorkflowIDReusePolicy =temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy:temporalio.common.RetryPolicy |None =None, cron_schedule:str ='', memo:Mapping[str,Any] |None =None, search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |None =None, versioning_intent:VersioningIntent |None =None, static_summary:str |None =None, static_details:str |None =None, priority:temporalio.common.Priority =temporalio.common.Priority.default) ->ChildWorkflowHandle[Any,Any]:
(source)

Start a child workflow and return its handle.

Parameters
workflow:AnyString name or class method decorated with@workflow.runfor the workflow to start.
arg:AnySingle argument to the child workflow.
args:Sequence[Any]Multiple arguments to the child workflow. Cannot be set if arg is.
id:str |NoneOptional unique identifier for the workflow execution. If not set,defaults touuid4.
task_queue:str |NoneTask queue to run the workflow on. Defaults to the currentworkflow's task queue.
result_type:type |NoneFor string workflows, this can set the specific result typehint to deserialize into.
cancellation_type:ChildWorkflowCancellationTypeHow the child workflow will react to cancellation.
parent_close_policy:ParentClosePolicyHow to handle the child workflow when the parentworkflow closes.
execution_timeout:timedelta |NoneTotal workflow execution timeout includingretries and continue as new.
run_timeout:timedelta |NoneTimeout of a single workflow run.
task_timeout:timedelta |NoneTimeout of a single workflow task.
id_reuse_policy:temporalio.common.WorkflowIDReusePolicyHow already-existing IDs are treated.
retry_policy:temporalio.common.RetryPolicy |NoneRetry policy for the workflow.
cron_schedule:strSeehttps://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
memo:Mapping[str,Any] |NoneMemo for the workflow.
search_attributes:temporalio.common.SearchAttributes |temporalio.common.TypedSearchAttributes |NoneSearch attributes for the workflow. The dictionaryform of this is DEPRECATED.
versioning_intent:VersioningIntent |NoneWhen using the Worker Versioning feature, specifies whether this ChildWorkflow should run on a worker with a compatible Build Id or not.Deprecated: Use Worker Deployment versioning instead.
static_summary:str |NoneA single-line fixed summary for this child workflow execution that may appearin the UI/CLI. This can be in single-line Temporal markdown format.
static_details:str |NoneGeneral fixed details for this child workflow execution that may appear inUI/CLI. This can be in Temporal markdown format and can span multiple lines. This isa fixed value on the workflow that cannot be updated. For details that can beupdated, useWorkflow.get_current_details within the workflow.
priority:temporalio.common.PriorityPriority to use for this workflow.
Returns
ChildWorkflowHandle[Any,Any]A workflow handle to the started/existing workflow.
@overload
defstart_local_activity(activity:CallableAsyncNoParam[ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity(activity:CallableSyncNoParam[ReturnType], *, activity_id:str |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity(activity:CallableAsyncSingleParam[ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity(activity:CallableSyncSingleParam[ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity(activity:Callable[...,Awaitable[ReturnType]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity(activity:Callable[...,ReturnType], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity(activity:str, arg:Any =temporalio.common._arg_unset, *, args:Sequence[Any] = [], result_type:type |None =None, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[Any]:
(source)

Start a local activity and return its handle.

At least one ofschedule_to_close_timeout orstart_to_close_timeoutmust be present.

Parameters
activity:AnyActivity name or function reference.
arg:AnySingle argument to the activity.
args:Sequence[Any]Multiple arguments to the activity. Cannot be set if arg is.
result_type:type |NoneFor string activities, this can set the specific resulttype hint to deserialize into.
schedule_to_close_timeout:timedelta |NoneMax amount of time the activity can take fromfirst being scheduled to being completed before it times out. Thisis inclusive of all retries.
schedule_to_start_timeout:timedelta |NoneMax amount of time the activity can take tobe started from first being scheduled.
start_to_close_timeout:timedelta |NoneMax amount of time a single activity run cantake from when it starts to when it completes. This is per retry.
retry_policy:temporalio.common.RetryPolicy |NoneHow an activity is retried on failure. If unset, anSDK-defined default is used. Set maximum attempts to 1 to disableretries.
local_retry_threshold:timedelta |NoneUndocumented
cancellation_type:ActivityCancellationTypeHow the activity is treated when it is cancelled fromthe workflow.
activity_id:str |NoneOptional unique identifier for the activity. This is anadvanced setting that should not be set unless users are sure theyneed to. Contact Temporal before setting this value.
summary:str |NoneOptional summary for the activity.
Returns
ActivityHandle[Any]An activity handle to the activity which is an async task.
@overload
defstart_local_activity_class(activity:type[CallableAsyncNoParam[ReturnType]], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_class(activity:type[CallableSyncNoParam[ReturnType]], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_class(activity:type[CallableAsyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_class(activity:type[CallableSyncSingleParam[ParamType,ReturnType]], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_class(activity:type[Callable[...,Awaitable[ReturnType]]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_class(activity:type[Callable[...,ReturnType]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None) ->ActivityHandle[ReturnType]:
(source)

Start a local activity from a callable class.

Seestart_local_activity for parameter and return details.

@overload
defstart_local_activity_method(activity:MethodAsyncNoParam[SelfType,ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_method(activity:MethodSyncNoParam[SelfType,ReturnType], *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_method(activity:MethodAsyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_method(activity:MethodSyncSingleParam[SelfType,ParamType,ReturnType], arg:ParamType, *, schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],Awaitable[ReturnType]], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
@overload
defstart_local_activity_method(activity:Callable[Concatenate[SelfType,MultiParamSpec],ReturnType], *, args:Sequence[Any], schedule_to_close_timeout:timedelta |None =None, schedule_to_start_timeout:timedelta |None =None, start_to_close_timeout:timedelta |None =None, retry_policy:temporalio.common.RetryPolicy |None =None, local_retry_threshold:timedelta |None =None, cancellation_type:ActivityCancellationType =ActivityCancellationType.TRY_CANCEL, activity_id:str |None =None, summary:str |None =None) ->ActivityHandle[ReturnType]:
(source)

Start a local activity from a method.

Seestart_local_activity for parameter and return details.

deftime() ->float: (source)

Current seconds since the epoch from the workflow perspective.

This is the workflow equivalent oftime.time.

Returns
floatSeconds since the epoch as a float.
deftime_ns() ->int: (source)

Current nanoseconds since the epoch from the workflow perspective.

This is the workflow equivalent oftime.time_ns.

Returns
intNanoseconds since the epoch
@overload
@overload
@overload
@overload
@overload
(source)

Decorator for a workflow update handler method.

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

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

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

Parameters
fn:CallableSyncOrAsyncType |NoneThe function to decorate.
name:str |NoneUpdate name. Defaults to method__name__. Cannot be presentwhendynamic is present.
dynamic:bool |NoneIf true, this handles all updates not otherwise handled. Theparameters of the method must be self, a string name, and a*args positional varargs. Cannot be present whenname ispresent.
unfinished_policy:HandlerUnfinishedPolicyActions taken if a workflow terminates witha running instance of this handler.
description:str |NoneA short description of the update that may appear in the UI/CLI.
defupsert_memo(updates:Mapping[str,Any]): (source)

Adds, modifies, and/or removes memos, with upsert semantics.

Every memo that has a matching key has its value replaced with the one specified inupdates.If the value is set toNone, the memo is removed instead.For every key with no existing memo, a new memo is added with specified value (unless the value isNone).Memos with keys not included inupdates remain unchanged.

defupsert_search_attributes(attributes:temporalio.common.SearchAttributes |Sequence[temporalio.common.SearchAttributeUpdate]): (source)

Upsert search attributes for this workflow.

Parameters
attributes:temporalio.common.SearchAttributes |Sequence[temporalio.common.SearchAttributeUpdate]The attributes to set. This should be a sequence ofupdates (i.e. values created via value_set and value_unset calls onsearch attribute keys). The dictionary form of attributes isDEPRECATED and if used, result in invalid key types on thetyped_search_attributes property in the info.
defuuid4() ->uuid.UUID: (source)

Get a new, determinism-safe v4 UUID based onrandom.

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

Returns
uuid.UUIDA deterministically-seeded v4 UUID.
@overload
async defwait(fs:Iterable[_FT], *, timeout:float |None =None, return_when:str =asyncio.ALL_COMPLETED) ->tuple[list[_FT],list[_FT]]:
@overload
(source)

Wait for the Futures or Tasks given by fs to complete.

This is a deterministic version ofasyncio.wait. This functionshould be used instead of that one in workflows.

async defwait_condition(fn:Callable[[],bool], *, timeout:timedelta |float |None =None, timeout_summary:str |None =None): (source)

Wait on a callback to become true.

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

Parameters
fn:Callable[[],bool]Non-async callback that accepts no parameters and returns a boolean.
timeout:timedelta |float |NoneOptional number of seconds to wait until throwingasyncio.TimeoutError.
timeout_summary:str |NoneOptional simple string identifying the timer (created iftimeout ispresent) that may be visible in UI/CLI. While it can be normal text, it is best to treatas a timer ID.
ServiceT = (source)

Undocumented

Value
TypeVar('ServiceT')
logger = (source)

Logger that will have contextual workflow details embedded.

Logs are skipped during replay by default.

def_assert_dynamic_handler_args(fn:Callable, arg_types:list[type] |None, is_method:bool) ->bool: (source)

Undocumented

def_bind_method(obj:Any, fn:Callable[...,Any]) ->Callable[...,Any]: (source)

Undocumented

def_is_unbound_method_on_cls(fn:Callable[...,Any], cls:type) ->bool: (source)

Undocumented

def_parameters_identical_up_to_naming(fn1:Callable, fn2:Callable) ->bool: (source)

Return True if the functions have identical parameter lists, ignoring parameter names.

def_release_waiter(waiter:asyncio.Future[Any], *args): (source)

Undocumented

def_set_current_update_info(info:UpdateInfo): (source)

Undocumented

def_update_validator(update_def:_UpdateDefinition, fn:Callable[...,None] |None =None) ->Callable[...,None] |None: (source)

Decorator for a workflow update validator method.

async def_wait(fs:Iterable[asyncio.Future |asyncio.Task], timeout:float |None, return_when:str, loop:asyncio.AbstractEventLoop) ->tuple[list,list]: (source)

Undocumented

_FT = (source)

Undocumented

Value
TypeVar('_FT',bound=asyncio.Future[Any])
_current_update_info:contextvars.ContextVar[UpdateInfo] = (source)

Undocumented

_imports_passed_through = (source)

Undocumented

_in_sandbox = (source)

Undocumented

_sandbox_unrestricted = (source)

Undocumented


[8]ページ先頭

©2009-2025 Movatter.jp