Workflows and built-in tasks

Callbacks, chains and chords (see workflows).

What happens after a task: callbacks, chains and chords.

Celery’s worker does this when a task ends, from the embed part of the message (callbacks, errbacks, chain, chord). The runner does the same by publishing the next messages to the queue:

  • link callbacks receive the result as first argument.

  • chain carries the remaining steps; the last element of the list is the next one.

  • link_error callbacks receive the failed task id (Celery’s classic errback form).

  • chord: every header task increments a counter in the backend when it ends; the one that reaches the size of the group collects the results of all the header tasks and sends the chord body with the list as its only argument. If any header task failed, the body is stored as FAILURE with a ChordError.

celery_cloud.runners.canvas.dispatch_failure(task: Task, queue: QueueRef) → None[source]

Run what must follow a task that failed (errbacks, chord accounting).

celery_cloud.runners.canvas.dispatch_success(task: Task, result: Any, queue: QueueRef) → None[source]

Run what must follow a task that finished successfully.

celery_cloud.runners.canvas.on_chord_part_return(task: Task, queue: QueueRef) → None[source]

Count a finished header task and, if it is the last one, run the chord body.

celery.map and celery.starmap

Celery’s built-in tasks that run other tasks: celery.map and celery.starmap.

task.map([...]), task.starmap([...]) and task.chunks(...) (which the client expands into several celery.starmap messages) are executed by a Celery worker as tasks of their own. The runner runs them the same way: it calls the task named in the embedded signature once per item, in this invocation, and returns the list of results. The named task must be listed in TASKS like any other.

celery_cloud.runners.builtin_tasks.run_builtin(task: Task, executor: TaskExecutor) → list[Any][source]

Run celery.map / celery.starmap and return the results in order.