Skip to main content

Community-maintained durable execution SDK for AWS Lambda in Python

Project description

Async Durable Execution for Python

Build PyPI - Version PyPI - Python Version OpenSSF Scorecard License


Build reliable, long-running AWS Lambda workflows with checkpointed steps, waits, callbacks, and parallel execution.

This package is distributed from a community-maintained fork of the original Apache-2.0 licensed AWS project and continues under Apache License 2.0 with upstream notices preserved.

This fork is specifically focused on making async Python work naturally with durable functions. The public API remains synchronous at the durable operation boundary, but user-provided durable callables must now use async def for handlers, steps, child contexts, callback submitters, and condition checks.

✨ Key Features

  • Async-only user callables - Durable handlers and user-provided durable callbacks must use async def
  • Automatic checkpointing - Resume execution after Lambda pauses or restarts
  • Durable steps - Run work with retry strategies and deterministic replay
  • Waits and callbacks - Pause for time or external signals without blocking Lambda
  • Parallel and map operations - Fan out work with configurable completion criteria
  • Child contexts - Structure complex workflows into isolated subflows
  • Replay-safe logging - Use standard logging loggers enriched by the durable context filter
  • Local and cloud testing - Validate workflows with the testing SDK
  • Async Python support - Use async def for handlers, steps, child contexts, callback submitters, and wait-for-condition checks

📦 Packages

Package Description Version
async-durable-execution Execution SDK for Lambda durable functions PyPI - Version
async-durable-execution-runner Local/cloud test runner and pytest helpers PyPI - Version
async-durable-execution-examples Example durable functions and integration tests for local and cloud workflows Shared repo version

🚀 Quick Start

This fork now requires async callables for all user-provided durable code. Requires Python 3.10 or newer.

Install the execution SDK:

pip install async-durable-execution

Create a durable Lambda handler:

import asyncio
import logging
from datetime import timedelta

from async_durable_execution import (
    durable_step,
    durable_execution,
    step,
    wait,
)

logger = logging.getLogger(__name__)


@durable_step
async def validate_order(order_id: str) -> dict:
    await asyncio.sleep(0)
    logger.info("Validating order", extra={"order_id": order_id})
    return {"order_id": order_id, "valid": True}


@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")

    return {"status": "approved", "order_id": order_id}

Async callables are required anywhere the SDK accepts user code, including map() item functions, parallel() branches, child contexts, callback submitters, and wait-for-condition checks. Durable context operations are awaitable and run on the same event loop as your handler:

import asyncio
import logging

from async_durable_execution import (
    durable_step,
    durable_execution,
    step,
)

logger = logging.getLogger(__name__)


@durable_step
async def fetch_order(order_id: str) -> dict:
    await asyncio.sleep(0)
    logger.info("Fetched order", extra={"order_id": order_id})
    return {"order_id": order_id, "status": "ready"}


@durable_execution
async def handler(event: dict) -> dict:
    order = await step(fetch_order(event["order_id"]), name="fetch_order")
    return {"order": order}

📚 Documentation

The complete documentation for the AWS Durable Execution SDK for Python lives on the AWS Documentation site:

💬 Feedback & Support

📄 License

See the LICENSE file for our project's licensing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async_durable_execution-2.0.0a2.tar.gz (203.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_durable_execution-2.0.0a2-py3-none-any.whl (89.9 kB view details)

Uploaded Python 3

File details

Details for the file async_durable_execution-2.0.0a2.tar.gz.

File metadata

File hashes

Hashes for async_durable_execution-2.0.0a2.tar.gz
Algorithm Hash digest
SHA256 18adde287d594296c25fe9b7173f630d9f13f6faf0c417835ee2acc25b3fef91
MD5 a8f7b5cca03e91a3ca59b24485978247
BLAKE2b-256 8dfce3262a23f4d3a2c9f3be96766d8cdf1720ff29bd66c1bdf54bd991cc57ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_durable_execution-2.0.0a2.tar.gz:

Publisher: pypi-publish.yml on zhongkechen/async-durable-execution

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file async_durable_execution-2.0.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for async_durable_execution-2.0.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 eb8acde221ea7b61ebf38143c7039013001e3a2ac029d13aa36fb784711284bf
MD5 123f9f7da7fa7f7c3731979c2ad9a950
BLAKE2b-256 5898b534eaf671bb99071d0fe2256186b41e12bf8dffd2ed3f3a4b1c8aa78f4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_durable_execution-2.0.0a2-py3-none-any.whl:

Publisher: pypi-publish.yml on zhongkechen/async-durable-execution

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page