Skip to content

Activity

activity

Activity decorator, registry, and execution context.

ActivityInfo dataclass

ActivityInfo(task_id, activity_type, activity_attempt_id, attempt_number, task_queue, worker_id)

Metadata attached to the currently running activity attempt.

ActivityContext

ActivityContext(*, info, client)

Per-attempt activity context exposed by :func:durable_workflow.activity.context.

info property

info

Metadata for the currently running activity attempt.

is_cancelled property

is_cancelled

True once the server has signalled that the owning workflow cancelled this activity.

heartbeat async

heartbeat(details=None)

Report liveness to the server and check for a cancellation request.

Long-running activities should call heartbeat() periodically so the server can distinguish a slow-but-alive attempt from a dead worker. Optional details are attached to the heartbeat and surface as the activity's last-known progress on failure.

Raises :class:~durable_workflow.errors.ActivityCancelled when the owning workflow has requested cancellation, so the activity can exit cleanly at its next natural break point.

context

context()

Return the current activity attempt context.

defn

defn(*, name)

Register a callable as an activity type under a language-neutral name.

registry

registry()

Return a copy of activity callables registered in this process.