module documentation

Undocumented

Class ChildWorkflowCancellationType How a child workflow cancellation should be handled.
Class ChildWorkflowConfig TypedDict of config that can be used for start_child_workflow and execute_child_workflow.
Class ChildWorkflowHandle Handle for interacting with a child workflow.
Class ExternalWorkflowHandle Handle for interacting with an external workflow.
Class ParentClosePolicy How a child workflow should be handled when the parent closes.
Exception ContinueAsNewError Error thrown by continue_as_new.
Function all_handlers_finished Whether update and signal handlers have finished executing.
Function continue_as_new Stop the workflow immediately and continue as new.
Async Function execute_child_workflow Start a child workflow and wait for completion.
Function get_dynamic_query_handler Get the dynamic query handler if any.
Function get_dynamic_signal_handler Get the dynamic signal handler if any.
Function get_dynamic_update_handler Get the dynamic update handler if any.
Function get_external_workflow_handle Get a workflow handle to an existing workflow by its ID.
Function get_external_workflow_handle_for Get a typed workflow handle to an existing workflow by its ID.
Function get_query_handler Get the query handler for the given name if any.
Function get_signal_handler Get the signal handler for the given name if any.
Function get_update_handler Get the update handler for the given name if any.
Function set_dynamic_query_handler Set or unset the dynamic query handler.
Function set_dynamic_signal_handler Set or unset the dynamic signal handler.
Function set_dynamic_update_handler Set or unset the dynamic update handler.
Function set_query_handler Set or unset the query handler for the given name.
Function set_signal_handler Set or unset the signal handler for the given name.
Function set_update_handler Set or unset the update handler for the given name.
Async Function start_child_workflow Start a child workflow and return its handle.
def all_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 prevent interruption 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.
def continue_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = None, versioning_intent: VersioningIntent | None = None, initial_versioning_behavior: ContinueAsNewVersioningBehavior | None = None) -> NoReturn:
def continue_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = None, versioning_intent: VersioningIntent | None = None, initial_versioning_behavior: ContinueAsNewVersioningBehavior | None = None) -> NoReturn:
def continue_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = None, versioning_intent: VersioningIntent | None = None, initial_versioning_behavior: ContinueAsNewVersioningBehavior | None = None) -> NoReturn:
def continue_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = None, versioning_intent: VersioningIntent | None = None, initial_versioning_behavior: ContinueAsNewVersioningBehavior | None = None) -> NoReturn:
def continue_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = None, versioning_intent: VersioningIntent | None = None, initial_versioning_behavior: ContinueAsNewVersioningBehavior | 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 arg is.
workflow:None | Callable | strSpecific workflow to continue to. Defaults to the current workflow.
task_queue:str | NoneTask queue to run the workflow on. Defaults to the current workflow's task queue.
run_timeout:timedelta | NoneTimeout of a single workflow run. Defaults to the current workflow's run timeout.
task_timeout:timedelta | NoneTimeout of a single workflow task. Defaults to the current workflow'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:None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributesSearch attributes for the workflow. Defaults to the current workflow's search attributes. The dictionary form of this is DEPRECATED.
versioning_intent:VersioningIntent | NoneWhen using the Worker Versioning feature, specifies whether this Workflow should Continue-as-New onto a worker with a compatible Build Id or not. Deprecated: Use Worker Deployment versioning instead.
initial_versioning_behavior:ContinueAsNewVersioningBehavior | NoneUndocumented
Returns
NoReturnNever returns, always raises a ContinueAsNewError.
Raises
ContinueAsNewErrorAlways raised by this function. Should not be caught but instead be allowed to
async def execute_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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:
async def execute_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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:
async def execute_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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:
async def execute_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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 for await (await start_child_workflow ).

def get_dynamic_query_handler() -> Callable | None: (source)

Get the dynamic query handler if any.

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

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

Get the dynamic signal handler if any.

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

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

Get the dynamic update handler if any.

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

Returns
Callable | NoneCallable for the dynamic update handler if any.
def get_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.
def get_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 as get_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.
def get_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.
def get_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.
def get_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.
def set_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.
def set_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.
def set_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.
def set_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 handlers created via the @workflow.query decorator.

Parameters
name:strName of the query.
handler:Callable | NoneCallable to set or None to unset.
def set_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 handlers created via the @workflow.signal decorator.

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

Parameters
name:strName of the signal.
handler:Callable | NoneCallable to set or None to unset.
def set_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 handlers created 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.
async def start_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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]:
async def start_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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]:
async def start_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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]:
async def start_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: None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributes = 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.run for 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 to uuid4.
task_queue:str | NoneTask queue to run the workflow on. Defaults to the current workflow's task queue.
result_type:type | NoneFor string workflows, this can set the specific result type hint to deserialize into.
cancellation_type:ChildWorkflowCancellationTypeHow the child workflow will react to cancellation.
parent_close_policy:ParentClosePolicyHow to handle the child workflow when the parent workflow closes.
execution_timeout:timedelta | NoneTotal workflow execution timeout including retries 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:strSee https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
memo:Mapping[str, Any] | NoneMemo for the workflow.
search_attributes:None | temporalio.common.SearchAttributes | temporalio.common.TypedSearchAttributesSearch attributes for the workflow. The dictionary form of this is DEPRECATED.
versioning_intent:VersioningIntent | NoneWhen using the Worker Versioning feature, specifies whether this Child Workflow should run on a worker with a compatible Build Id or not. Deprecated: Use Worker Deployment versioning instead.
static_summary:str | NoneA single-line fixed summary for this child workflow execution that may appear in the UI/CLI. This can be in single-line Temporal markdown format.
static_details:str | NoneGeneral fixed details for this child workflow execution that may appear in UI/CLI. This can be in Temporal markdown format and can span multiple lines. This is a fixed value on the workflow that cannot be updated. For details that can be updated, use 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.