Skip to content

send_task_heartbeat

send_task_heartbeat(
    task_token: TaskToken, *, config_overrides: Optional[SFNClientConfig] = None
) -> SendTaskHeartbeatOutput

Used by activity workers and Task states using the callback pattern, and optionally Task states using the job run pattern to report to Step Functions that the task represented by the specified taskToken is still making progress. This action resets the Heartbeat clock. The Heartbeat threshold is specified in the state machine's Amazon States Language definition (HeartbeatSeconds). This action does not in itself create an event in the execution history. However, if the task times out, the execution history contains an ActivityTimedOut entry for activities, or a TaskTimedOut entry for tasks using the job run or callback pattern.

The Timeout of a task, defined in the state machine's Amazon States Language definition, is its maximum allowed duration, regardless of the number of SendTaskHeartbeat requests received. Use HeartbeatSeconds to configure the timeout interval for heartbeats.

Parameters:

Raises:

  • InvalidToken –

    The provided token is not valid.

  • TaskDoesNotExist –

    The activity does not exist.

  • TaskTimedOut –

    The task token has either expired or the task associated with the token has already been closed.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sfn/_services/sfn.py
def send_task_heartbeat(
    self,
    task_token: "capo_sfn.types.task_token.TaskToken",
    *,
    config_overrides: Optional[SFNClientConfig] = None,
) -> "capo_sfn.types.send_task_heartbeat_output.SendTaskHeartbeatOutput":
    """<p>Used by activity workers and Task states using the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token">callback</a> pattern, and optionally Task states using the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-sync">job run</a> pattern to report to Step Functions that the task represented by the specified <code>taskToken</code> is still making progress. This action resets the <code>Heartbeat</code> clock. The <code>Heartbeat</code> threshold is specified in the state machine's Amazon States Language definition (<code>HeartbeatSeconds</code>). This action does not in itself create an event in the execution history. However, if the task times out, the execution history contains an <code>ActivityTimedOut</code> entry for activities, or a <code>TaskTimedOut</code> entry for tasks using the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-sync">job run</a> or <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token">callback</a> pattern.</p> <note> <p>The <code>Timeout</code> of a task, defined in the state machine's Amazon States Language definition, is its maximum allowed duration, regardless of the number of <a>SendTaskHeartbeat</a> requests received. Use <code>HeartbeatSeconds</code> to configure the timeout interval for heartbeats.</p> </note>

    Args:
        task_token: <p>The token that represents this task. Task tokens are generated by Step Functions when tasks are assigned to a worker, or in the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html">context object</a> when a workflow enters a task state. See <a>GetActivityTaskOutput$taskToken</a>.</p>

    Raises:
        capo_sfn.errors.invalid_token.InvalidToken: <p>The provided token is not valid.</p>
        capo_sfn.errors.task_does_not_exist.TaskDoesNotExist: <p>The activity does not exist.</p>
        capo_sfn.errors.task_timed_out.TaskTimedOut: <p>The task token has either expired or the task associated with the token has already been closed.</p>
        capo_sfn.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sfn.types.send_task_heartbeat_input.SendTaskHeartbeatInput]",
    ) -> OperationResponse[
        "capo_sfn.types.send_task_heartbeat_output.SendTaskHeartbeatOutput"
    ]:
        import capo_sfn._operations.aws_step_functions.send_task_heartbeat

        output, http_response = (
            capo_sfn._operations.aws_step_functions.send_task_heartbeat.send_task_heartbeat(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SendTaskHeartbeat")
    )
    input_: capo_sfn.types.send_task_heartbeat_input.SendTaskHeartbeatInput = {
        "task_token": task_token
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output