Skip to main content

Python SDK

The Python SDK provides a clean interface for writing TaskDaemon handlers.

Installation

The published Python SDK supports the examples below:
Alternatively, install a reviewed source revision:
Use a reviewed SDK revision or release for deployment. Keep diagnostic logs on stderr; the handler protocol uses stdout for one response per task. A request starts with attempt: 1; retries require a valid retryable error and remaining stored budget.

Basic Usage

Task Object

The Task dataclass contains:

Return Types

Success

Return Success with a result (any JSON-serializable value):

Error

Return Error with an error message and optional retryable flag:

Complete Example

This image handler needs pillow and requests in addition to the SDK:

Error Handling

Exceptions are automatically caught and converted to non-retryable errors:
For explicit error handling:

Dockerfile

Use python -u for unbuffered output to ensure responses are sent immediately.

Handler Configuration

Multiple task types can use the same image - the handler receives task.task_type to differentiate.