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:
ModelDynamodb model to store Celery tasks.
- Parameters:
Model (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- 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
- 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:
DuplicateTaskException – If the task already exists.
BackendException – On any other backend error.
- 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
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 (resultholds 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:
ModelThe counter item of a chord (
chord_count, as in Celery’s backend).- 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
- 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