Skip to content

Callback

Operation module: async_durable_execution._operation.callback.

Create a callback when an external system will resume the durable execution.

User-facing durable callback operation.

Classes

CallbackError

CallbackError(message: str, callback_id: str | None = None)

Bases: ExecutionError

Error in callback handling.

Callback

Callback(
    callback_id: str,
    operation_id: str,
    state: ExecutionState,
    serdes: SerDes[T] | None = None,
)

Bases: Generic[T]

A future that will block on result() until callback_id returns.

Methods:

result async
result() -> T | None

Return the result of the future. Will block until result is available.

This will suspend the current execution while waiting for the result to become available. Durable Functions will replay the execution once the result is ready, and proceed when it reaches the .result() call.

Use the callback id with the following APIs to send back the result, error or heartbeats: SendDurableExecutionCallbackSuccess, SendDurableExecutionCallbackFailure and SendDurableExecutionCallbackHeartbeat.

Functions:

create_callback

create_callback(
    *,
    name: str | None = None,
    timeout: Duration | None = None,
    heartbeat_timeout: Duration | None = None,
    serdes: SerDes | None = None,
) -> Task[Callback]

Create a durable callback handle that external systems can complete later.

Parameters:

Name Type Description Default
name str | None

Optional durable operation name.

None
timeout Duration | None

Optional maximum time to wait for callback completion.

None
heartbeat_timeout Duration | None

Optional maximum time to wait between callback heartbeats.

None
serdes SerDes | None

Optional serializer for callback results.

None