This document describes Celery 2.3. For development docs, go here.


class celery.task.sets.TaskSet(task=None, tasks=None, app=None, Publisher=None)

A task containing several subtasks, making it possible to track how many, or when all of the tasks have been completed.

Parameters:tasks – A list of subtask instances.


>>> urls = ("", "")
>>> taskset = TaskSet(refresh_feed.subtask((url, )) for url in urls)
>>> taskset_result = taskset.apply_async()
>>> list_of_return_values = taskset_result.join()  # *expensive*

Applies the taskset locally by blocking until all tasks return.

apply_async(connection=None, connect_timeout=None, publisher=None, taskset_id=None)

Apply taskset.

total = None

Total number of subtasks in this set.

class celery.task.sets.subtask(task=None, args=None, kwargs=None, options=None, **ex)

Class that wraps the arguments and execution options for a single task invocation.

Used as the parts in a TaskSet or to safely pass tasks around as callbacks.

  • task – Either a task class/instance, or the name of a task.
  • args – Positional arguments to apply.
  • kwargs – Keyword arguments to apply.
  • options – Additional options to celery.execute.apply_async().

Note that if the first argument is a dict, the other arguments will be ignored and the values in the dict will be used instead.

>>> s = subtask("tasks.add", args=(2, 2))
>>> subtask(s)
{"task": "tasks.add", args=(2, 2), kwargs={}, options={}}
apply(args=(), kwargs={}, **options)

Apply this task locally.

apply_async(args=(), kwargs={}, **options)

Apply this task asynchronously.

delay(*argmerge, **kwmerge)

Shortcut to apply_async(argmerge, kwargs).


Previous topic


Next topic


This Page