Result backend model

TaskModel is the PynamoDB model of the DynamoDB table. It writes the same item layout as Celery’s own DynamoDB backend (see Backend item format).

class celery_cloud.models.task_model.TaskModel(hash_key: Any | None = None, range_key: Any | None = None, _user_instantiated: bool = True, **attributes: Any)[source]

Bases: Model

Dynamodb model to store Celery tasks.

Parameters:

Model (_type_) – _description_

Returns:

_description_

Return type:

_type_

exception DoesNotExist(msg: str | None = None, cause: Exception | None = None)

Bases: DoesNotExist

class Meta[source]

Bases: object

aws_access_key_id = None
aws_secret_access_key = None
aws_session_token = None
connect_timeout_seconds = 15
extra_headers = None
host = None
max_pool_connections = 10
max_retry_attempts = 3
read_timeout_seconds = 30
region = 'eu-west-1'
table_name = 'celery'
attempt

A number attribute

classmethod delete_task(task_uuid: str) → None[source]

Remove the item of a task (so a redelivered message runs it again).

classmethod get_task(task_uuid: str, consistent: bool = False) → dict[str, Any] | None[source]

Ges task status and decode result

Parameters:

task_uuid (str) – _description_

Returns:

_description_

Return type:

Optional[dict]

id

A unicode attribute

classmethod insert_task(task_uuid: str, meta: dict[str, Any] | None = None, retries: int = 0) → TaskModel[source]

Insert a new task with the correct prefix.

The write is conditional: only the first delivery of a message creates the task, so a duplicate SQS delivery is never executed twice.

Parameters:

task_uuid (str) – Celery task id.

Raises:
classmethod is_revoked(task_uuid: str) → bool[source]

True when the client revoked the task.

revoked

A class for boolean attributes

classmethod store_result(task_uuid: str, status: str, result: Any | None = None, traceback: str | None = None) → None[source]

Write the state of a task unconditionally (creating the item if needed).

Used for tasks that never started, such as the body of a chord whose header failed.

timestamp

A number attribute

ttl

A number attribute

classmethod update_task(task_uuid: str, status: str, result: Any | None = None, traceback: str | None = None, meta: dict[str, Any] | None = None) → TaskModel | None[source]

Update task status

Parameters:
  • task_uuid (str) – _description_

  • status (str) – _description_

  • result (Optional[Any], optional) – Defaults to None.

  • traceback (Optional[str], optional) – Defaults to None.

  • meta (dict, optional) – Extended meta (name, args, kwargs, worker, retries, queue) to store with the result.

Returns:

_description_

Return type:

_type_

TaskModel.result is a binary attribute that holds the JSON of the Celery meta (status, result, traceback, children, date_done, task_id).

Chords

The group and counter items that Celery’s DynamoDB backend keeps for chords.

Backend items that Celery uses to run groups and chords.

Celery’s DynamoDB backend keeps two kinds of items next to the task results, in the same table and with the same id hash key:

  • b'celery-taskset-meta-<group id>': written by the client when it starts a chord, it lists the ids of the header tasks (result holds the JSON of the group result).

  • b'chord-unlock-<group id>': a counter (chord_count) that every header task increments when it finishes; the one that reaches the size of the group runs the chord body.

The runner reads and updates them exactly as Celery’s worker does.

class celery_cloud.models.canvas_model.ChordCounter(hash_key: Any | None = None, range_key: Any | None = None, _user_instantiated: bool = True, **attributes: Any)[source]

Bases: Model

The counter item of a chord (chord_count, as in Celery’s backend).

exception DoesNotExist(msg: str | None = None, cause: Exception | None = None)

Bases: DoesNotExist

class Meta[source]

Bases: object

aws_access_key_id = None
aws_secret_access_key = None
aws_session_token = None
connect_timeout_seconds = 15
extra_headers = None
host = None
max_pool_connections = 10
max_retry_attempts = 3
read_timeout_seconds = 30
region = 'eu-west-1'
table_name = 'celery'
chord_count

A number attribute

classmethod delete_for(group_id: str) → None[source]
id

A unicode attribute

classmethod increment(group_id: str) → int[source]

Atomically add one to the counter and return the new value.

timestamp

A number attribute

celery_cloud.models.canvas_model.delete_group(group_id: str) → None[source]

Remove the group item once the chord is finished.

celery_cloud.models.canvas_model.group_children(group_id: str) → list[str] | None[source]

Ids of the tasks of a group, in order (None when the group does not exist).