Lambda handler

celery_cloud.runners.aws_lambda contains the entry point of the runner: lambda_handler. Configure it as the handler of the Lambda function (celery_cloud.runners.aws_lambda.lambda_handler).

celery_cloud.runners.aws_lambda.lambda_handler(event: dict[str, Any], context: Any) → dict[str, Any][source]

Lambda handler for processing Celery Broker events

Every record of the batch is processed independently. Failures are reported in the response and, when the task state could not be stored in the backend, in batchItemFailures so SQS delivers the message again (requires ReportBatchItemFailures in the event source mapping).

Parameters:
  • event – AWS Lambda event (only SQS is supported by now).

  • context – AWS Lambda context.

Returns:

A serialized LambdaResponse.

Return type:

dict[str, Any]

celery_cloud.runners.aws_lambda.call_task(task: Task, seconds_left: float | None = None) → Any[source]

Execute a Celery task and return the result.

Parameters:
  • task – The task to run.

  • seconds_left – Seconds before AWS stops the invocation (None = unknown). The task is stopped before that, with the time limits of the message.