Registry / azure / durabletask

durabletask

JSON →
library1.5.0pypypi✓ verified 84d ago

The `durabletask` library is a Python Client SDK for the Azure Durable Task Scheduler, enabling developers to define, schedule, and manage resilient and stateful workflows (orchestrations) using ordinary Python code. It is designed for building fault-tolerant, long-running processes. The current version is 1.4.0, and the project maintains an active release cadence.

pip install durabletask
INSTALL
IMPORT
SIG · DURABLETASK
D
durabletask
azurepythonv1.5.0
Install
3.1s avg
Import
—
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 42MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 3.1s · import 0.000s · 40MB
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DurableTaskClient
✓ from durabletask import task
✗ from durabletask import DurableTaskClient
OrchestrationWorkItemFilter
✓ from durabletask import OrchestrationWorkItemFilter
ActivityWorkItemFilter
✓ from durabletask import ActivityWorkItemFilter

This quickstart demonstrates a simple 'Hello World' orchestration. It defines an activity (`HelloActivity`) and an orchestrator (`HelloOrchestrator`), registers them with a worker, and then schedules a new orchestration instance using the client. It assumes a Durable Task Scheduler emulator is running locally on `http://localhost:8080` (e.g., via Docker) and uses environment variables for configuration.

import os from durabletask import DurableTaskClient, DurableTaskWorker, OrchestrationContext, Task, TaskActivity # NOTE: For local development, ensure the Durable Task Scheduler emulator is running. # For example, using Docker: docker run --name dtsemulator -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest CONNECTION_STRING = os.environ.get("DURABLETASK_CONNECTION_STRING", "Endpoint=http://localhost:8080;Authentication=None") TASK_HUB_NAME = os.environ.get("DURABLETASK_TASK_HUB_NAME", "default") class HelloActivity(TaskActivity): async def run(self, context: OrchestrationContext, input: str) -> str: print(f"Executing HelloActivity with input: {input}") return f"Hello, {input}!" class HelloOrchestrator(TaskActivity): async def run(self, context: OrchestrationContext, input: str) -> str: print(f"Starting HelloOrchestrator with input: {input}") # Call an activity function result = await context.call_activity("HelloActivity", input) print(f"Orchestrator received result: {result}") return result async def main(): client = DurableTaskClient(CONNECTION_STRING, TASK_HUB_NAME) # Register orchestrators and activities with the worker worker = DurableTaskWorker( CONNECTION_STRING, TASK_HUB_NAME, orchestrators={ "HelloOrchestrator": HelloOrchestrator() }, activities={ "HelloActivity": HelloActivity() } ) async with worker: print("Worker started. Starting orchestration...") # Start a new orchestration instance_id = await client.schedule_new_orchestration("HelloOrchestrator", "World") print(f"Orchestration instance started: {instance_id}") # Wait for the orchestration to complete status = await client.wait_for_orchestration_completion(instance_id, timeout_in_seconds=60) if status: print(f"Orchestration '{instance_id}' completed. Status: {status.runtime_status}, Output: {status.output}") else: print(f"Orchestration '{instance_id}' did not complete within the timeout.") if __name__ == "__main__": import asyncio asyncio.run(main())
Debug
Known issues
breakingPython 3.9 support was removed in version 1.3.0. The library now requires Python 3.10 or newer.
fix
Upgrade your Python environment to 3.10 or a later supported version.
affects: >=1.3.0
gotchaOrchestrator functions must be deterministic. Avoid direct use of non-deterministic operations like `datetime.datetime.now()` or `random.random()` within orchestrator code, as this can lead to replay mismatches and unexpected behavior. Instead, use context-provided deterministic alternatives.
fix
For current time, use `context.current_utc_datetime` or similar deterministic APIs provided by the SDK. Ensure all operations within orchestrators are replayable.
affects: all
gotchaWhen using `context.task_all` (or `Task.all`) to run multiple activities in parallel, the orchestration will fail immediately upon the *first* activity's failure, even if other activities might succeed. Error details are encapsulated in `TaskFailedException`.
fix
Wrap calls to activities in `try/except` blocks within your orchestrator to handle individual activity failures gracefully. Inspect `TaskFailedException.FailureDetails` for root cause information. Python does not support custom retry handlers directly in orchestrators; implement retry logic with loops, exception handling, and timers.
affects: all
gotchaThis SDK is *not* directly compatible with Azure Durable Functions. If you are building Durable Functions, use the `azure-functions-durable` package and its associated tools. This SDK targets the standalone Durable Task Scheduler.
fix
For Azure Durable Functions, refer to the Azure Functions documentation and use the appropriate SDK for your language (e.g., `azure-functions-durable` for Python).
affects: all
gotchaIncorrect connection string formats are a common cause of startup failures, especially when switching between local development (emulator) and Azure deployments.
fix
Ensure the connection string matches the expected format: `Endpoint=http://localhost:8080;Authentication=None` for the local emulator (note `http` and port 8080) or `Endpoint=https://<scheduler-name>.durabletask.io;...` for Azure (note `https`). Verify `Authentication` parameter and port usage.
affects: all
Upgrade
Version history
1.5.0latest on PyPI · released Jun 5, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
durabletask — pip install durabletask · libregistry