This document describes an older version of Celery (2.1). For the latest stable version please go here.
A task containing several subtasks, making it possible to track how many, or when all of the tasks has been completed.
Parameters: | tasks – A list of subtask instances. |
---|
Total number of subtasks in this task set.
Example:
>>> from djangofeeds.tasks import RefreshFeedTask
>>> from celery.task.sets import TaskSet, subtask
>>> urls = ("http://cnn.com/rss",
... "http://bbc.co.uk/rss",
... "http://xkcd.com/rss")
>>> subtasks = [RefreshFeedTask.subtask(kwargs={"feed_url": url})
... for url in urls]
>>> taskset = TaskSet(tasks=subtasks)
>>> taskset_result = taskset.apply_async()
>>> list_of_return_values = taskset_result.join()
alias of TaskPublisher
Applies the taskset locally.
Run all tasks in the taskset.
Returns a celery.result.TaskSetResult instance.
Example
>>> ts = TaskSet(tasks=(
... RefreshFeedTask.subtask(["http://foo.com/rss"]),
... RefreshFeedTask.subtask(["http://bar.com/rss"]),
... ))
>>> result = ts.apply_async()
>>> result.taskset_id
"d2c9b261-8eff-4bfb-8459-1e1b72063514"
>>> result.subtask_ids
["b4996460-d959-49c8-aeb9-39c530dcde25",
"598d2d18-ab86-45ca-8b4f-0779f5d6a3cb"]
>>> result.waiting()
True
>>> time.sleep(10)
>>> result.ready()
True
>>> result.successful()
True
>>> result.failed()
False
>>> result.join()
[True, True]
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.
Parameters: |
|
---|
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 this task locally.
Apply this task asynchronously.
Shortcut to apply_async(argmerge, kwargs).