---
title: "Basic Parent Flow"
description: "Start one SubFlow for each input and wait for every SubFlow to complete."
canonical_url: "https://docs.superdurable.io/design-patterns/subflows/basic/"
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.go.md) · [Java](https://docs.superdurable.io/design-patterns/subflows/basic.java.md) · [TypeScript](https://docs.superdurable.io/design-patterns/subflows/basic.typescript.md) · [Rust](https://docs.superdurable.io/design-patterns/subflows/basic.rust.md)

Start one SubFlow for each input and wait for every SubFlow to complete.

**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)

The SubFlows Step's WaitFor builds one SubFlow condition per request and combines them with `allOf`. The parent resumes only after all children finish. Use this shape when you need neither partial completion nor cancellation.

## 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/subflows.md)
