---
title: "SubFlow"
description: "This page lists the Python SDK names for SubFlows."
canonical_url: "https://docs.superdurable.io/zh-Hans/reference/python/subflow/"
source: "docs/reference/python/subflow.mdx"
locale: "zh-Hans"
---

# SubFlow

This page lists the Python SDK names for [SubFlows](https://docs.superdurable.io/zh-Hans/concepts/primitives/subflow.md).
The doc comment of each API gives its parameters, defaults, and errors. Read
them in the [Python SDK API reference](https://docs.superdurable.io/zh-Hans/reference/python.md#api-reference).

<a id="api-names"></a>

## API names

| Task                                                 | Python API                                                                      | Dex behavior                                                                                                     |
| ---------------------------------------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Start a child Flow and wait for it                   | **SubFlow\.run** in **wait_for**                                                | [SubFlows](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflows)                       |
| Set the child timeout, Attributes, and configuration | **SubFlowOptions**                                                              | [SubFlowOptions](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-options)          |
| Choose what happens to an existing child             | **reuse_policy** of **SubFlowOptions**, with **SubFlowReusePolicy**             | [SubFlowReusePolicy](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-reuse-policy) |
| Read the child result                                | **SubFlow\.get_condition_results** in **execute**. It returns a **FlowResult**. | [SubFlow results](https://docs.superdurable.io/zh-Hans/reference/python/waits.md#subflow-results)                |
| Read the generated child Flow ID                     | **SubFlow\.get_flow_id**                                                        | [SubFlowReusePolicy](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-reuse-policy) |
| Stop a child that lost an **AnyOf**                  | **Client.stop_flow** with the child Flow ID                                     | [Stop a Flow](https://docs.superdurable.io/zh-Hans/reference/server/runtime-client.md#stop-a-flow)               |

<a id="step-types-that-start-subflows"></a>

## 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.

<a id="example"></a>

## Example

Example: [examples/python/dex_examples/primitives/subflow/parent_flow.py](https://github.com/superdurable/dex/tree/main/examples/python/dex_examples/primitives/subflow/parent_flow.py)
