Asynchronous Execution¶
FlowerPower integrates with Hamilton’s asynchronous driver to let you await pipeline runs inside event loops (e.g., FastAPI, notebooks, asyncio scripts).
This page explains how to use PipelineManager.run_async, what the
RunConfig.async_driver toggle does, and how async execution parallels the
behaviour of synchronous runs.
Quick start¶
With additional modules¶
You can compose multiple modules in async mode just like sync mode using
additional_modules:
RunConfig.async_driver¶
RunConfig.async_drivercontrols whether the async driver is used.- Default behaviour when calling
run_async(...)is to use the async driver. - Setting
async_driver=Falseraises aValueError– usepm.run(...)for synchronous execution instead.
Parity with synchronous runs¶
Async runs honour the same flags and behaviours:
reload=Truereloads the main and additional modules before executing.log_levelconfigures logging for the run.- Adapters and adapter configs are applied the same as in sync mode.
Requirements¶
Async execution relies on hamilton.async_driver. Ensure your Hamilton version
provides it, and upgrade if necessary:
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
ImportError: hamilton.async_driver |
Hamilton version too old | pip install -U hamilton |
ValueError: async_driver=False |
Explicit opt-out for async runs | Use pm.run(...) for sync or set async_driver=True |
| Event loop errors | Running asyncio.run inside an active loop |
Use a framework’s lifecycle (e.g., FastAPI startup) or nest_asyncio in notebooks |
Related¶
- Compose Pipelines With Additional Modules
- README: “Asynchronous Execution” section