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 the examples, helpers, and package direction here prioritize async def handlers, steps, child contexts, callback submitters, and condition checks.

✨ Key Features

  • Async-first fork - This fork prioritizes making async def workflows feel natural with durable functions
  • 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 context.logger for structured, de-duplicated logs
  • 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 recommends writing new durable workflows with async callables by default.

Install the execution SDK:

pip install async-durable-execution

Create a durable Lambda handler:

import asyncio

from async_durable_execution import (
    DurableContext,
    StepContext,
    durable_execution,
    durable_step,
)
from async_durable_execution.config import Duration


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


@durable_execution
async def handler(event: dict, context: DurableContext) -> dict:
    order_id = event["order_id"]
    context.logger.info("Starting workflow", extra={"order_id": order_id})

    validation = context.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)
    context.wait(duration=Duration.from_seconds(5), name="await_confirmation")

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

Async callables are supported anywhere the SDK accepts user code, including map() item functions, parallel() branches, child contexts, callback submitters, and wait-for-condition checks. The public Durable APIs stay synchronous, so async work is awaited transparently for you:

import asyncio

from async_durable_execution import (
    DurableContext,
    StepContext,
    durable_execution,
    durable_step,
)


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


@durable_execution
async def handler(event: dict, context: DurableContext) -> dict:
    order = context.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.0a1.tar.gz (215.5 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.0a1-py3-none-any.whl (98.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for async_durable_execution-2.0.0a1.tar.gz
Algorithm Hash digest
SHA256 f4fdc56323084ebd27b2f8abad31d40d1559e00f5c45ff1da14f34092d40a467
MD5 cb613ae0305746d92fdb5bb9c7e739c6
BLAKE2b-256 8df19d1941ca925d9a9f4bfec7b42aa2987a27de31fc9b865e85b3356bc3952d

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_durable_execution-2.0.0a1.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.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for async_durable_execution-2.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 2694bc63266a144bcd3f8f36a2862f4c762993d2769821c7912af1554f84dc48
MD5 f48aba09355630f7ab2b6e26a38e9313
BLAKE2b-256 3f0a74ad7c75bf5e743329c71730b4d55d2ed384f1f19bb6142632ca84f7b536

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_durable_execution-2.0.0a1-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