Skip to main content

SubFlow

View as Markdown

This page lists the Python SDK names for SubFlows. The doc comment of each API gives its parameters, defaults, and errors. Read them in the Python SDK API reference.

API names​

TaskPython APIDex behavior
Start a child Flow and wait for itSubFlow.run in wait_forSubFlows
Set the child timeout, Attributes, and configurationSubFlowOptionsSubFlowOptions
Choose what happens to an existing childreuse_policy of SubFlowOptions, with SubFlowReusePolicySubFlowReusePolicy
Read the child resultSubFlow.get_condition_results in execute. It returns a FlowResult.SubFlow results
Read the generated child Flow IDSubFlow.get_flow_idSubFlowReusePolicy
Stop a child that lost an AnyOfClient.stop_flow with the child Flow IDStop a Flow

Step types that start SubFlows​

Changed in 1.45: a Step whose Step type contains "-" cannot start SubFlows.

The generated child Flow ID is SubFlow:{parent Flow ID}-{Step execution ID}-{index}. The Step execution ID is {Step type}-{n}. Because the parts are joined with "-", a dash in the Step type makes the child Flow ID ambiguous. For example, parent a-b at Step type C and parent a at Step type b-C would both get SubFlow:a-b-C-1-0.

The default Step type is the Step class name, which contains no dash. Only an override of get_step_type can add one. When such a Step returns a Wait that contains SubFlow.run, the server rejects the result as an invalid Worker response. It fails the attempt without retry, so the Flow fails under the default policy. The Worker sends the result unchanged and logs a warning that names the Step type. The Step can still wait on Timers and Channels.

To migrate, rename the Step type so it contains no dash.

Example​

Example: examples/python/dex_examples/primitives/subflow/parent_flow.py