Exceptions

All the exceptions of the runner derive from RunnerBaseException. The handler never lets them escape: it converts them into a FAILURE state in the backend, a failed task in the response, or an entry in batchItemFailures (see Concepts and behaviour).

exception celery_cloud.exceptions.runner_base_exception.RunnerBaseException(message: str, detail: str | None = None)[source]

Bases: Exception

Base Domain exception for runner errors

Parameters:
  • message (str) – Human readable description of the error.

  • detail (str | None) – Extra information (original error, payload…).

__init__(message: str, detail: str | None = None) → None[source]
exception celery_cloud.exceptions.runner_exceptions.BackendException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception for backend errors

exception celery_cloud.exceptions.runner_exceptions.DuplicateTaskException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception: the task already exists in the backend.

SQS delivers messages at least once, so this is the expected way a duplicate delivery shows up. It must not be executed again.

exception celery_cloud.exceptions.runner_exceptions.EventDecodeException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception for message decoding errors

exception celery_cloud.exceptions.runner_exceptions.MessageDecodeException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception for message decoding errors

exception celery_cloud.exceptions.runner_exceptions.ResultTooLargeException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception: the task result does not fit in a backend item.

Retrying cannot help, so it is stored as a task failure instead of being treated as a backend outage.

exception celery_cloud.exceptions.runner_exceptions.RevokedTaskException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception: the task was revoked before it started.

exception celery_cloud.exceptions.runner_exceptions.TaskDecodeException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception for task decoding errors

exception celery_cloud.exceptions.runner_exceptions.TaskExecutionException(message: str, detail: str | None = None)[source]

Bases: RunnerBaseException

Domain exception for execution exceptions

Exceptions for task code

Raised or used inside tasks (from celery_cloud import ...). The client receives the Celery classes of the same name.

Exceptions raised inside task code by the runner itself.

They are plain Exception subclasses (not RunnerBaseException) because user code can catch them, exactly as with Celery’s own classes of the same name. celery_module tells the runner which module to report in a FAILURE result: the Celery client rebuilds the exception from exc_module + exc_type, so reporting celery.exceptions makes except celery.exceptions.SoftTimeLimitExceeded work on the client.

exception celery_cloud.exceptions.task_exceptions.Ignore[source]

Bases: Exception

Raised by a task to end without storing any result (the state is left as is).

Typical use: update the state yourself with update_state and then raise Ignore().

celery_module = 'celery.exceptions'
exception celery_cloud.exceptions.task_exceptions.MaxRetriesExceededError[source]

Bases: Exception

retry() was called more times than max_retries allows.

celery_module = 'celery.exceptions'
exception celery_cloud.exceptions.task_exceptions.Reject(reason: str | None = None, requeue: bool = False)[source]

Bases: Exception

Raised by a task to reject its message.

Parameters:
  • reason – Why it was rejected.

  • requeue – When True the message goes back to SQS and the task runs again. When False the task is stored as REJECTED and dropped.

__init__(reason: str | None = None, requeue: bool = False) → None[source]
celery_module = 'celery.exceptions'
exception celery_cloud.exceptions.task_exceptions.Retry(exc: BaseException | None = None, countdown: float | None = None, eta: datetime | None = None, message: str | None = None)[source]

Bases: Exception

Raised by retry(): the runner re-sends the task instead of failing it.

Parameters:
  • exc – The exception that caused the retry (reported if retries run out).

  • countdown – Seconds to wait before the next attempt.

  • eta – Absolute time (datetime) of the next attempt; wins over countdown.

__init__(exc: BaseException | None = None, countdown: float | None = None, eta: datetime | None = None, message: str | None = None) → None[source]
celery_module = 'celery.exceptions'
exception celery_cloud.exceptions.task_exceptions.SoftTimeLimitExceeded[source]

Bases: Exception

The soft time limit of the task expired (the task may clean up).

celery_module = 'celery.exceptions'
exception celery_cloud.exceptions.task_exceptions.TimeLimitExceeded[source]

Bases: Exception

The hard time limit expired, or the Lambda function is about to time out.

celery_module = 'celery.exceptions'