class WorkflowHandle(Generic[SelfType, ReturnType]):
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 | query |
Query the workflow. |
Async Method | result |
Wait for result of the workflow. |
Async Method | signal |
Send a signal to the workflow. |
Async Method | terminate |
Terminate the workflow. |
Property | first |
Run ID used for cancel and terminate calls if present to ensure the cancel and terminate happen for 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 |
Run ID used for signal and query calls if present to ensure the query or signal happen on this exact run. |
Instance Variable | _client |
Undocumented |
Instance Variable | _first |
Undocumented |
Instance Variable | _id |
Undocumented |
Instance Variable | _result |
Undocumented |
Instance Variable | _result |
Undocumented |
Instance Variable | _run |
Undocumented |
Create workflow handle.
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.
Raises | |
RPCError | Workflow could not be cancelled. |
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.
Returns | |
WorkflowExecutionDescription | Workflow details. |
Raises | |
RPCError | Workflow details could not be fetched. |
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:Iterable[ | Multiple arguments to the query. Cannot be set if arg is. |
rejectOptional[ | Condition for rejecting the query. If unset/None, defaults to the client's default (which is defaulted to None). |
Returns | |
Any | Result of the query. |
Raises | |
WorkflowQueryRejectedError | A query reject condition was satisfied. |
RPCError | Workflow details could not be fetched. |
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. |
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. |
@overload
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:Iterable[ | Multiple arguments to the signal. Cannot be set if arg is. |
Raises | |
RPCError | Workflow could not be signalled. |
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. |
Raises | |
RPCError | Workflow could not be terminated. |
Run ID used for cancel
and terminate
calls if
present to ensure the cancel and terminate happen for 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.
Run ID used for signal
and query
calls if
present to ensure the query or signal happen on 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.