This document describes Celery 2.4. For development docs, go here.
celery.task.sets¶
celery.task.sets¶
Creating and applying groups of tasks.
copyright: |
|
---|---|
license: | BSD, see LICENSE for more details. |
-
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.Example:
>>> urls = ("http://cnn.com/rss", "http://bbc.co.uk/rss") >>> taskset = TaskSet(refresh_feed.subtask((url, )) for url in urls) >>> taskset_result = taskset.apply_async() >>> list_of_return_values = taskset_result.join() # *expensive*
-
apply
(taskset_id=None)¶ Applies the taskset locally by blocking until all tasks return.
-
apply_async
(connection=None, connect_timeout=None, publisher=None, taskset_id=None)¶ Apply taskset.
-
task
¶
-
task_name
¶
-
tasks
¶
-
total
= None¶ Total number of subtasks in this set.
-
-
celery.task.sets.
maybe_subtask
(t)¶
-
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.Parameters: - 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).
-
type
¶