SubFlow
View as MarkdownThis 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
| Task | Python API | Dex behavior |
|---|---|---|
| Start a child Flow and wait for it | SubFlow.run in wait_for | SubFlows |
| Set the child timeout, Attributes, and configuration | SubFlowOptions | SubFlowOptions |
| Choose what happens to an existing child | reuse_policy of SubFlowOptions, with SubFlowReusePolicy | SubFlowReusePolicy |
| Read the child result | SubFlow.get_condition_results in execute. It returns a FlowResult. | SubFlow results |
| Read the generated child Flow ID | SubFlow.get_flow_id | SubFlowReusePolicy |
| Stop a child that lost an AnyOf | Client.stop_flow with the child Flow ID | Stop 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