Async Durable Execution for Python
Build fully compliant, long-running AWS Lambda workflows with native
async/await. Checkpoint state automatically, pause without active compute,
and resume after failures without running a workflow server.
Project Status
Fully compliant with the AWS Durable Execution conformance suite. Every upstream requirement is continuously validated against deployed Lambda functions in CI.
The project also maintains extensive local and cloud runner coverage, publishes generated API documentation and coverage reports, and includes executable examples for async durable workflows.
Community-maintained async fork of the Apache-2.0 licensed AWS Durable Execution Python SDK.
This project continues to ship under Apache License 2.0 with the upstream notices preserved.
The fork exists because the official Python SDK does not support
async/await, making integration with asyncio libraries difficult. This SDK
adds async durable callables, background operation tasks, direct asyncio task
composition, and APIs designed for modern Python applications.
✨ Key Features
- Async-first durable code - Compared with the official AWS SDK, user-provided durable handlers, steps, child contexts,
flownodes, callback submitters, map item functions, parallel branches, and wait-for-condition checks are written withasync def. - Operations not available in the official SDK - This SDK adds replay-safe helpers (
random(),now(),timestamp(), anduuid()) and durable self-invocation (recurse()). - Stable custom operation SPI - Third-party packages can reserve opaque deterministic primitive identities, use custom subtypes, and build stateful replay-safe operations without importing SDK internals.
- Declarative DAG workflows - Define acyclic workflows with typed node inputs, inferred or conditional dependencies, failure routes, and durable operations inside each node. The SDK validates the graph before execution and skips nodes that are not required by the selected outputs.
- Background operation tasks - Durable operations such as
step(...),wait(...),invoke(...),recurse(...),run_in_child_context(...), andflow(...)returnasyncio.Taskobjects, so independent operations can run in the background and be awaited together withasyncio.gatherwithout usingparallel()ormap(). - Pythonic operation parameters - Operations use direct keyword arguments, standard Python types such as
datetime.timedelta, and keyword-only names instead of configuration wrapper objects. - Integrated local and cloud runner - Runner functionality now ships through
async_durable_execution, with separate local and cloud runner factories and typed test result helpers. - Async Lambda client support - Install the optional
aiobotoextra to use an async Lambda client; otherwise the SDK uses the bundled sync client through an async adapter. - Replay-aware logging with stdlib logging - Standard
loggingloggers are enriched by durable context filtering so workflow logs remain replay safe. - Lambda layer packaging - The repo includes tooling and workflows to build and publish an SDK Lambda layer for functions that do not vendor dependencies directly.
🚀 Quick Start
Install the execution SDK:
pip install async-durable-execution
For an async Lambda service client, install the optional aioboto extra:
pip install "async-durable-execution[aioboto]"
The aioboto extra installs aiobotocore, which lets the SDK create an async Lambda client for durable checkpoint and state APIs. Without it, the SDK uses the bundled botocore dependency through a threaded async adapter.
Create a durable Lambda handler:
import logging
from datetime import timedelta
from async_durable_execution import (
durable_callable,
durable_execution,
step,
wait,
)
logger = logging.getLogger(__name__)
@durable_callable
async def validate_order(order_id: str) -> dict:
logger.info("Validating order", extra={"order_id": order_id})
return {"order_id": order_id, "valid": True}
@durable_callable
async def create_receipt(order_id: str) -> dict:
logger.info("Creating receipt", extra={"order_id": order_id})
return {"receipt_id": f"receipt-{order_id}", "order_id": order_id}
@durable_execution
async def handler(event: dict) -> dict:
order_id = event["order_id"]
logger.info("Starting workflow", extra={"order_id": order_id})
validation = await step(validate_order(order_id), name="validate_order")
if not validation["valid"]:
return {"status": "rejected", "order_id": order_id}
# simulate approval (real world: use wait_for_callback)
await wait(duration=timedelta(seconds=5), name="await_confirmation")
receipt = await step(create_receipt(order_id), name="create_receipt")
return {"status": "approved", "order_id": order_id, "receipt": receipt}
Durable operations return asyncio.Task objects. If you call an operation without immediately awaiting it, it is scheduled to run in the background and can be awaited later. This lets independent operations run concurrently with normal asyncio patterns:
import asyncio
pricing_tasks = [
step(price_line_item(item), name=f"price-{item['sku']}")
for item in items
]
priced_items = await asyncio.gather(*pricing_tasks)
🧪 Testing Durable Functions
The SDK includes runner helpers for testing durable functions locally or against deployed Lambda functions. The local runner executes the durable handler in process, intercepts checkpoint operations with an in-memory service client, and returns a DurableFunctionTestResult that can be inspected by operation name.
Assuming the Quick Start handler above is saved in order_workflow.py, a local test can run the same durable function:
import json
from async_durable_execution import (
DurableFunctionTestResult,
InvocationStatus,
create_local_runner,
)
from order_workflow import handler
async def test_my_durable_function() -> None:
with create_local_runner(
handler=handler,
input={"order_id": "order-123"},
timeout=10,
) as runner:
result: DurableFunctionTestResult = await runner.run()
receipt = {"receipt_id": "receipt-order-123", "order_id": "order-123"}
assert result.status is InvocationStatus.SUCCEEDED
assert result.result == json.dumps(
{"status": "approved", "order_id": "order-123", "receipt": receipt}
)
validation_result = result.get_step("validate_order")
assert validation_result.step_details is not None
assert validation_result.step_details.result == json.dumps(
{"order_id": "order-123", "valid": True}
)
receipt_result = result.get_step("create_receipt")
assert receipt_result.step_details is not None
assert receipt_result.step_details.result == json.dumps(receipt)
After deploying the same handler to Lambda, use the cloud runner to test the deployed durable function. The function name must be qualified with a version or alias, for example order-workflow:$LATEST or order-workflow:prod.
import os
from async_durable_execution import InvocationStatus, create_cloud_runner
async def test_order_workflow_in_cloud() -> None:
with create_cloud_runner(
function_name=os.environ["ORDER_WORKFLOW_FUNCTION_NAME"],
region=os.environ.get("AWS_REGION", "us-east-1"),
input={"order_id": "order-123"},
timeout=45,
) as runner:
result = await runner.run()
receipt = {"receipt_id": "receipt-order-123", "order_id": "order-123"}
assert result.status is InvocationStatus.SUCCEEDED
assert result.get_deserialized_result() == {
"status": "approved",
"order_id": "order-123",
"receipt": receipt,
}
🧩 Examples
Example durable functions live in examples/. Start with hello_world.py for the smallest complete handler.
The example tests in test_examples/ are also useful as executable recipes. Browse them by operation or pattern:
step/,wait/,wait_for_callback/, andwait_for_condition/for core durable operationsstep/steps_with_gather.pyfor starting multiple step tasks and awaiting them together withasyncio.gatherflow/,map/,parallel/, andrun_in_child_context/for composition patternsinvoke/, includinginvoke/recurse.py,with_retry/,callback/, andlogger_example/for integrations and operational behavior
For the developer workflow to run or deploy example integration tests, see the Contributing Guide.
📚 Documentation
- Documentation Site - Searchable guides and API reference generated from Python docstrings
- DAG Workflow API - Build declarative workflows with
flow(), typed node inputs, conditional dependencies, and failure routes - Official Python SDK Comparison - Side-by-side comparison with the official AWS Durable Execution Python SDK
- Migration Guide - Move from the official synchronous Python SDK to this async-first SDK
- Workflow Patterns - Build agentic loops, human approval workflows, and compensating transactions
- Deploy and Invoke - Configure IAM, qualified function identifiers, invocations, CloudFormation, and SAM
- Using Synchronous Code - Wrap existing synchronous business logic and blocking clients safely
- Advanced Usage - Explore background operation tasks, batch completion conditions, Lambda clients, and Lambda layers
- Custom Durable Operations - Build third-party durable operation libraries on the stable extension-author interface
- Runner Architecture - Local and cloud runner execution flow, components, and diagrams
- Contributing Guide - Development workflow, Hatch commands, testing, and pull request guidance
References
- AWS Durable Execution Documentation - Concepts, getting started, core operations, advanced topics, and API reference
- AWS Lambda Durable Functions Guide - How durable functions work on Lambda
💬 Feedback & Support
📄 License
See the LICENSE file for our project's licensing.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_durable_execution-2.3.0.tar.gz.
File metadata
- Download URL: async_durable_execution-2.3.0.tar.gz
- Upload date:
- Size: 130.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b35a3b8a470314bdadf11a22b8797338227a7aefd778a6ef0d4a1de1a6af3071
|
|
| MD5 |
c96cf33fb769d15528f49f788e7552dc
|
|
| BLAKE2b-256 |
ce3f40aedab7753ffa468ebf8b8b3d7e85f166cd24ed19354f862ecefd8730b9
|
Provenance
The following attestation bundles were made for async_durable_execution-2.3.0.tar.gz:
Publisher:
pypi-publish.yml on zhongkechen/async-durable-execution
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_durable_execution-2.3.0.tar.gz -
Subject digest:
b35a3b8a470314bdadf11a22b8797338227a7aefd778a6ef0d4a1de1a6af3071 - Sigstore transparency entry: 2494949569
- Sigstore integration time:
-
Permalink:
zhongkechen/async-durable-execution@00b7120215a868df41c91bb15e724d4284139ba6 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/zhongkechen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@00b7120215a868df41c91bb15e724d4284139ba6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file async_durable_execution-2.3.0-py3-none-any.whl.
File metadata
- Download URL: async_durable_execution-2.3.0-py3-none-any.whl
- Upload date:
- Size: 169.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe59d9298f25d67597c9b1d59f716e44ceb939fd76b1c5007f9658fcaabe9dd1
|
|
| MD5 |
ee02c25daa44d31b4e797f62d0bf5439
|
|
| BLAKE2b-256 |
3f2cd63efddd41d7ec329ced2dcdf1c9af74ea8764363e07e16b6d51d4de27df
|
Provenance
The following attestation bundles were made for async_durable_execution-2.3.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on zhongkechen/async-durable-execution
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_durable_execution-2.3.0-py3-none-any.whl -
Subject digest:
fe59d9298f25d67597c9b1d59f716e44ceb939fd76b1c5007f9658fcaabe9dd1 - Sigstore transparency entry: 2494949618
- Sigstore integration time:
-
Permalink:
zhongkechen/async-durable-execution@00b7120215a868df41c91bb15e724d4284139ba6 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/zhongkechen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@00b7120215a868df41c91bb15e724d4284139ba6 -
Trigger Event:
release
-
Statement type: