Async Support for Dagster
Actively maintained. Last release 5 months ago. A safe choice.
pip install dagster-async-executordagster-async-executor
An executor for Dagster that adds native asyncio support for ops and assets.
dagster-async-executor lets you:
- Run
async defops without manually managing event loops or thread pools. - Mix sync and async ops in the same job.
- Use dynamic / fan-out graphs with async upstream and downstream dependencies.
- Keep the familiar Dagster executor interface, while enabling more scalable, concurrency‑friendly workloads (e.g. I/O‑heavy tasks, service calls, and streaming patterns).
This integration is a community‑maintained port of the original core PR: dagster-io/dagster#32833.
Installation
pip install dagster-async-executor
Quickstart
Use the async_executor when defining your job and write your ops as async def:
import anyio
import dagster as dg
from dagster_async_executor import async_executor
NUM_FANOUTS = 300
SLEEP_SECONDS = 3
@dg.op(out=dg.DynamicOut())
async def create_dynamic_outputs():
"""Creates a dynamic number of outputs."""
for i in range(NUM_FANOUTS):
yield dg.DynamicOutput(value=f"item_{i}", mapping_key=f"key_{i}")
@dg.op
async def process_item(context: dg.OpExecutionContext, item: str):
"""Process each item from the fan-out."""
context.log.info(f"[{context.op_handle}] sleeping...")
await anyio.sleep(SLEEP_SECONDS)
context.log.info(f"[{context.op_handle}] completed")
return item
@dg.op
async def collect_results(context: dg.OpExecutionContext, results: list):
"""Collect all results from the fan-out."""
context.log.info(f"[{context.op_handle}] collected {len(results)} results")
return results
@dg.job(executor_def=async_executor)
def simple_fanout_job():
# no need to use await
dynamic_items = create_dynamic_outputs()
processed = dynamic_items.map(process_item)
collect_results(processed.collect())
Run the job as usual (e.g. via Dagit, dagster job execute, or your orchestration environment). From the outside, this executor behaves like a standard Dagster executor – but internally it uses async orchestration.
How it works
At a high level, dagster-async-executor introduces an AsyncExecutor that:
- Reuses Dagster’s machinery.