class WorkflowHandle(Generic[
Known subclasses: temporalio.testing._workflow._TimeSkippingWorkflowHandle
Constructor: WorkflowHandle(client, id, run_id, result_run_id, ...)
Handle for interacting with a workflow.
This is usually created via Client.get_workflow_handle
or
returned from Client.start_workflow
.
Method | __init__ |
Create workflow handle. |
Async Method | cancel |
Cancel the workflow. |
Async Method | describe |
Get workflow details. |
Async Method | execute |
Send an update request to the workflow and wait for it to complete. |
Async Method | fetch |
Get workflow history. |
Method | fetch |
Get workflow history events as an async iterator. |
Method | get |
Get a handle for an update. The handle can be used to wait on the update result. |
Method | get |
Get a typed handle for an update. The handle can be used to wait on the update result. |
Async Method | query |
Query the workflow. |
Async Method | result |
Wait for result of the workflow. |
Async Method | signal |
Send a signal to the workflow. |
Async Method | start |
Send an update request to the workflow and return a handle to it. |
Async Method | terminate |
Terminate the workflow. |
Property | first |
Run ID used to ensure requested operations apply to a workflow ID started with this run ID. |
Property | id |
ID for the workflow. |
Property | result |
Run ID used for result calls if present to ensure result is for a workflow starting from this run. |
Property | run |
If present, run ID used to ensure that requested operations apply to this exact run. |
Method | _fetch |
Undocumented |
Async Method | _start |
Undocumented |
Instance Variable | __temporal |
Undocumented |
Instance Variable | _client |
Undocumented |
Instance Variable | _first |
Undocumented |
Instance Variable | _id |
Undocumented |
Instance Variable | _result |
Undocumented |
Instance Variable | _result |
Undocumented |
Instance Variable | _run |
Undocumented |
Client
, id: str
, *, run_id: Optional[ str]
= None, result_run_id: Optional[ str]
= None, first_execution_run_id: Optional[ str]
= None, result_type: Optional[ Type]
= None):
(source)
¶
Create workflow handle.
Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None):
(source)
¶
Cancel the workflow.
This will issue a cancellation for run_id
if present. This
call will make sure to use the run chain starting from
first_execution_run_id
if present. To create handles with
these values, use Client.get_workflow_handle
.
Warning
Handles created as a result of Client.start_workflow
with
a start signal will cancel the latest workflow with the same
workflow ID even if it is unrelated to the started workflow.
Parameters | |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Raises | |
RPCError | Workflow could not be cancelled. |
Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowExecutionDescription
:
(source)
¶
Get workflow details.
This will get details for run_id
if present. To use a
different run ID, create a new handle with via
Client.get_workflow_handle
.
Warning
Handles created as a result of Client.start_workflow
will
describe the latest workflow with the same workflow ID even if it is
unrelated to the started workflow.
Parameters | |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Returns | |
WorkflowExecutionDescription | Workflow details. |
Raises | |
RPCError | Workflow details could not be fetched. |
temporalio.workflow.UpdateMethodMultiParam[ [ SelfType], LocalReturnType]
, *, id: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> LocalReturnType
:temporalio.workflow.UpdateMethodMultiParam[ [ SelfType, ParamType], LocalReturnType]
, arg: ParamType
, *, id: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> LocalReturnType
:temporalio.workflow.UpdateMethodMultiParam[ MultiParamSpec, LocalReturnType]
, *, args: MultiParamSpec.args
, id: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> LocalReturnType
:str
, arg: Any
= temporalio.common._arg_unset, *, args: Sequence[ Any]
= [], id: Optional[ str]
= None, result_type: Optional[ Type]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> Any
:Send an update request to the workflow and wait for it to complete.
This will target the workflow with run_id
if present. To use a
different run ID, create a new handle with via Client.get_workflow_handle
.
Warning
This API is experimental
Parameters | |
update:Union[ | Update function or name on the workflow. |
arg:Any | Single argument to the update. |
args:Sequence[ | Multiple arguments to the update. Cannot be set if arg is. |
id:Optional[ | ID of the update. If not set, the default is a new UUID. |
resultOptional[ | For string updates, this can set the specific result type hint to deserialize into. |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Returns | |
Any | Undocumented |
Raises | |
WorkflowUpdateFailedError | If the update failed. |
WorkflowUpdateRPCTimeoutOrCancelledError | This update call timed out or was cancelled. This doesn't mean the update itself was timed out or cancelled. |
RPCError | There was some issue sending the update to the workflow. |
WorkflowHistoryEventFilterType
= WorkflowHistoryEventFilterType.ALL_EVENT, skip_archival: bool
= False, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowHistory
:
(source)
¶
Get workflow history.
This is a shortcut for fetch_history_events
that just fetches
all events.
Optional[ int]
= None, next_page_token: Optional[ bytes]
= None, wait_new_event: bool
= False, event_filter_type: WorkflowHistoryEventFilterType
= WorkflowHistoryEventFilterType.ALL_EVENT, skip_archival: bool
= False, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowHistoryEventAsyncIterator
:
(source)
¶
Get workflow history events as an async iterator.
This does not make a request until the first iteration is attempted. Therefore any errors will not occur until then.
Parameters | |
pageOptional[ | Maximum amount to fetch per request if any maximum. |
nextOptional[ | A specific page token to fetch. |
waitbool | Whether the event fetching request will wait for new events or just return right away. |
eventWorkflowHistoryEventFilterType | Which events to obtain. |
skipbool | Whether to skip archival. |
rpcMapping[ | Headers used on each RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for each RPC call. |
Returns | |
WorkflowHistoryEventAsyncIterator | An async iterator that doesn't begin fetching until iterated on. |
str
, *, workflow_run_id: Optional[ str]
= None, result_type: Optional[ Type]
= None) -> WorkflowUpdateHandle[ Any]
:
(source)
¶
Get a handle for an update. The handle can be used to wait on the update result.
Users may prefer the more typesafe get_update_handle_for
which accepts an update definition.
Warning
This API is experimental
Parameters | |
id:str | Update ID to get a handle to. |
workflowOptional[ | Run ID to tie the handle to. If this is not set,
the run_id will be used. |
resultOptional[ | The result type to deserialize into if known. |
Returns | |
WorkflowUpdateHandle[ | The update handle. |
temporalio.workflow.UpdateMethodMultiParam[ Any, LocalReturnType]
, id: str
, *, workflow_run_id: Optional[ str]
= None) -> WorkflowUpdateHandle[ LocalReturnType]
:
(source)
¶
Get a typed handle for an update. The handle can be used to wait on the update result.
This is the same as get_update_handle
but typed.
Warning
This API is experimental
Parameters | |
update:temporalio.workflow.UpdateMethodMultiParam[ | The update method to use for typing the handle. |
id:str | Update ID to get a handle to. |
workflowOptional[ | Run ID to tie the handle to. If this is not set,
the run_id will be used. |
Returns | |
WorkflowUpdateHandle[ | The update handle. |
MethodSyncOrAsyncNoParam[ SelfType, LocalReturnType]
, *, reject_condition: Optional[ temporalio.common.QueryRejectCondition]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> LocalReturnType
:MethodSyncOrAsyncSingleParam[ SelfType, ParamType, LocalReturnType]
, arg: ParamType
, *, reject_condition: Optional[ temporalio.common.QueryRejectCondition]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> LocalReturnType
:Callable[ Concatenate[ SelfType, MultiParamSpec], Union[ Awaitable[ LocalReturnType], LocalReturnType]]
, *, args: Sequence[ Any]
, reject_condition: Optional[ temporalio.common.QueryRejectCondition]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> LocalReturnType
:str
, arg: Any
= temporalio.common._arg_unset, *, args: Sequence[ Any]
= [], result_type: Optional[ Type]
= None, reject_condition: Optional[ temporalio.common.QueryRejectCondition]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> Any
:Query the workflow.
This will query for run_id
if present. To use a different
run ID, create a new handle with via
Client.get_workflow_handle
.
Warning
Handles created as a result of Client.start_workflow
will
query the latest workflow with the same workflow ID even if it is
unrelated to the started workflow.
Parameters | |
query:Union[ | Query function or name on the workflow. |
arg:Any | Single argument to the query. |
args:Sequence[ | Multiple arguments to the query. Cannot be set if arg is. |
resultOptional[ | For string queries, this can set the specific result type hint to deserialize into. |
rejectOptional[ | Condition for rejecting the query. If unset/None, defaults to the client's default (which is defaulted to None). |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Returns | |
Any | Result of the query. |
Raises | |
WorkflowQueryRejectedError | A query reject condition was satisfied. |
RPCError | Workflow details could not be fetched. |
bool
= True, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> ReturnType
:
(source)
¶
temporalio.testing._workflow._TimeSkippingWorkflowHandle
Wait for result of the workflow.
This will use result_run_id
if present to base the result on.
To use another run ID, a new handle must be created via
Client.get_workflow_handle
.
Parameters | |
followbool | If true (default), workflow runs will be continually fetched, until the most recent one is found. If false, the first result is used. |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for each RPC call. Note, this is the timeout for each history RPC call not this overall function. |
Returns | |
ReturnType | Result of the workflow after being converted by the data converter. |
Raises | |
WorkflowFailureError | Workflow failed, was cancelled, was
terminated, or timed out. Use the
WorkflowFailureError.cause to see the underlying
reason. |
Exception | Other possible failures during result fetching. |
MethodSyncOrAsyncNoParam[ SelfType, None]
, *, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None):MethodSyncOrAsyncSingleParam[ SelfType, ParamType, None]
, arg: ParamType
, *, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None):Callable[ Concatenate[ SelfType, MultiParamSpec], Union[ Awaitable[ None], None]]
, *, args: Sequence[ Any]
, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None):str
, arg: Any
= temporalio.common._arg_unset, *, args: Sequence[ Any]
= [], rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None):Send a signal to the workflow.
This will signal for run_id
if present. To use a different
run ID, create a new handle with via
Client.get_workflow_handle
.
Warning
Handles created as a result of Client.start_workflow
will
signal the latest workflow with the same workflow ID even if it is
unrelated to the started workflow.
Parameters | |
signal:Union[ | Signal function or name on the workflow. |
arg:Any | Single argument to the signal. |
args:Sequence[ | Multiple arguments to the signal. Cannot be set if arg is. |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Raises | |
RPCError | Workflow could not be signalled. |
temporalio.workflow.UpdateMethodMultiParam[ [ SelfType], LocalReturnType]
, *, wait_for_stage: WorkflowUpdateStage
, id: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowUpdateHandle[ LocalReturnType]
:temporalio.workflow.UpdateMethodMultiParam[ [ SelfType, ParamType], LocalReturnType]
, arg: ParamType
, *, wait_for_stage: WorkflowUpdateStage
, id: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowUpdateHandle[ LocalReturnType]
:temporalio.workflow.UpdateMethodMultiParam[ MultiParamSpec, LocalReturnType]
, *, args: MultiParamSpec.args
, wait_for_stage: WorkflowUpdateStage
, id: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowUpdateHandle[ LocalReturnType]
:str
, arg: Any
= temporalio.common._arg_unset, *, wait_for_stage: WorkflowUpdateStage
, args: Sequence[ Any]
= [], id: Optional[ str]
= None, result_type: Optional[ Type]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowUpdateHandle[ Any]
:Send an update request to the workflow and return a handle to it.
This will target the workflow with run_id
if present. To use a
different run ID, create a new handle with via Client.get_workflow_handle
.
Warning
This API is experimental
Parameters | |
update:Union[ | Update function or name on the workflow. arg: Single argument to the update. |
arg:Any | Undocumented |
waitWorkflowUpdateStage | Required stage to wait until returning: either ACCEPTED or COMPLETED. ADMITTED is not currently supported. See https://docs.temporal.io/workflows#update for more details. |
args:Sequence[ | Multiple arguments to the update. Cannot be set if arg is. |
id:Optional[ | ID of the update. If not set, the default is a new UUID. |
resultOptional[ | For string updates, this can set the specific result type hint to deserialize into. |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Returns | |
WorkflowUpdateHandle[ | Undocumented |
Raises | |
WorkflowUpdateRPCTimeoutOrCancelledError | This update call timed out or was cancelled. This doesn't mean the update itself was timed out or cancelled. |
RPCError | There was some issue sending the update to the workflow. |
Any
, reason: Optional[ str]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None):
(source)
¶
Terminate the workflow.
This will issue a termination for run_id
if present. This
call will make sure to use the run chain starting from
first_execution_run_id
if present. To create handles with
these values, use Client.get_workflow_handle
.
Warning
Handles created as a result of Client.start_workflow
with
a start signal will terminate the latest workflow with the same
workflow ID even if it is unrelated to the started workflow.
Parameters | |
*args:Any | Details to store on the termination. |
reason:Optional[ | Reason for the termination. |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpcOptional[ | Optional RPC deadline to set for the RPC call. |
Raises | |
RPCError | Workflow could not be terminated. |
Run ID used to ensure requested operations apply to a workflow ID started with this run ID.
This can be set when using Client.get_workflow_handle
. When
Client.start_workflow
is called without a start signal, this
is set to the resulting run.
This cannot be mutated. If a different first execution run ID is needed,
Client.get_workflow_handle
must be used instead.
Run ID used for result
calls if present to ensure result
is for a workflow starting from this run.
When this handle is created via Client.get_workflow_handle
,
this is the same as run_id. When this handle is created via
Client.start_workflow
, this value will be the resulting run
ID.
This cannot be mutated. If a different run ID is needed,
Client.get_workflow_handle
must be used instead.
If present, run ID used to ensure that requested operations apply to this exact run.
This is only created via Client.get_workflow_handle
.
Client.start_workflow
will not set this value.
This cannot be mutated. If a different run ID is needed,
Client.get_workflow_handle
must be used instead.
Optional[ str]
, *, page_size: Optional[ int]
= None, next_page_token: Optional[ bytes]
= None, wait_new_event: bool
= False, event_filter_type: WorkflowHistoryEventFilterType
= WorkflowHistoryEventFilterType.ALL_EVENT, skip_archival: bool
= False, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowHistoryEventAsyncIterator
:
(source)
¶
Undocumented
Union[ str, Callable]
, arg: Any
= temporalio.common._arg_unset, *, wait_for_stage: WorkflowUpdateStage
, args: Sequence[ Any]
= [], id: Optional[ str]
= None, result_type: Optional[ Type]
= None, rpc_metadata: Mapping[ str, str]
= {}, rpc_timeout: Optional[ timedelta]
= None) -> WorkflowUpdateHandle[ Any]
:
(source)
¶
Undocumented