---
title: "Basic Parent Flow"
description: "Start one SubFlow for each input and wait for every SubFlow to complete. Use it when every child must finish before the parent goes on, and you need neither partial completion nor cancellation."
canonical_url: "https://docs.superdurable.io/design-patterns/subflows/basic-parent-flow/"
source: "docs/content/design-patterns/subflows/basic.mdx"
locale: "en"
language: "python"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Basic Parent Flow

Code on this page is in Python. Other languages: [Go](https://docs.superdurable.io/design-patterns/subflows/basic-parent-flow.go.md) · [Java](https://docs.superdurable.io/design-patterns/subflows/basic-parent-flow.java.md) · [TypeScript](https://docs.superdurable.io/design-patterns/subflows/basic-parent-flow.typescript.md) · [Rust](https://docs.superdurable.io/design-patterns/subflows/basic-parent-flow.rust.md)

Start one SubFlow for each input and wait for every SubFlow to complete. Use it when every child must finish before the parent goes on, and you need neither partial completion nor cancellation.

**Flow graph: BasicParentFlow**

**Steps**

1. `SubFlows` (start Step): Run one child Flow per request and complete when all finish. Next: the Flow completes.

Example: [examples/python/dex_examples/patterns/parallel-subflows/basic_parent_flow.py](https://github.com/superdurable/dex/tree/main/examples/python/dex_examples/patterns/parallel-subflows/basic_parent_flow.py)

## How it works

The SubFlows Step's WaitFor builds one SubFlow condition per request and combines them with `allOf`. The parent resumes only after all children finish.

## Core implementation

**Python**

```python
class SubFlows(Step[list[str]]):
    def __init__(self, example_subflow: ExampleSubFlow) -> None:
        self.example_subflow = example_subflow

    def wait_for(self, context: Context, requests: list[str]) -> Wait:
        return Wait.all_of(
            *(SubFlow.run(self.example_subflow, request) for request in requests)
        )

    def execute(self, context: Context, requests: list[str]) -> StepDecision:
        return graceful_complete()


class BasicParentFlow(Flow[list[str]]):
    def __init__(self, example_subflow: ExampleSubFlow) -> None:
        self.subflows = SubFlows(example_subflow)

    def get_steps(self) -> StepList[list[str]]:
        return StepList.start_step(self.subflows)
```

Example: [examples/python/dex_examples/patterns/parallel-subflows/basic_parent_flow.py](https://github.com/superdurable/dex/tree/main/examples/python/dex_examples/patterns/parallel-subflows/basic_parent_flow.py)

## Next

- [Wait for half](https://docs.superdurable.io/design-patterns/subflows/wait-for-half.md)
- [SubFlows](https://docs.superdurable.io/design-patterns.md#subflows)
- [SubFlow](https://docs.superdurable.io/concepts/primitives/subflow.md)
