Skip to content

Recursive Invocation

Internal implementation module: async_durable_execution._operation.recurse.

Use recurse() to invoke the current Lambda function as a new durable execution. Unlike a Python recursive call, it does not grow the Python call stack. See recursive self-invocation for payload validation, recursion levels, Lambda permissions, and recursion protection.

Recursive self-invocation built on the backend-supported invoke operation.

Functions:

recurse

recurse(
    payload: P,
    *,
    name: str | None = None,
    function_name: str | None = None,
    with_recursive_level: bool = False,
    serdes_payload: SerDes[P] | None = None,
    serdes_result: SerDes[R] | None = None,
    tenant_id: str | None = None,
) -> Task[R]

Invoke the current durable Lambda function and wait for its result.

This is a convenience wrapper around :func:invoke for recursive workflows such as divide-and-conquer algorithms. Each recursive call is a separate durable execution, so the current execution records a chained invoke instead of growing a Python call stack.

Parameters:

Name Type Description Default
payload P

Payload to send to the recursive invocation.

required
name str | None

Optional durable operation name.

None
function_name str | None

Optional qualified Lambda function name or ARN. When omitted, the current Lambda context is used.

None
with_recursive_level bool

When true, copy the payload and set __recursive_level to the current context level plus one.

False
serdes_payload SerDes[P] | None

Optional serializer for the invocation payload.

None
serdes_result SerDes[R] | None

Optional deserializer for the invocation result.

None
tenant_id str | None

Optional tenant identifier. Defaults to the current Lambda context tenant id when present.

None