MCPcopy
hub / github.com/celery/celery / group

Class group

celery/canvas.py:1478–1946  ·  view source on GitHub ↗

Creates a group of tasks to be executed in parallel. A group is lazy so you must call it to take action and evaluate the group. Note: If only one argument is passed, and that argument is an iterable then that'll be used as the list of tasks instead: this allows

Source from the content-addressed store, hash-verified

1476
1477@Signature.register_type()
1478class group(Signature):
1479 """Creates a group of tasks to be executed in parallel.
1480
1481 A group is lazy so you must call it to take action and evaluate
1482 the group.
1483
1484 Note:
1485 If only one argument is passed, and that argument is an iterable
1486 then that'll be used as the list of tasks instead: this
1487 allows us to use ``group`` with generator expressions.
1488
1489 Example:
1490 >>> lazy_group = group([add.s(2, 2), add.s(4, 4)])
1491 >>> promise = lazy_group() # <-- evaluate: returns lazy result.
1492 >>> promise.get() # <-- will wait for the task to return
1493 [4, 8]
1494
1495 Arguments:
1496 *tasks (List[Signature]): A list of signatures that this group will
1497 call. If there&#x27;s only one argument, and that argument is an
1498 iterable, then that&#x27;ll define the list of signatures instead.
1499 **options (Any): Execution options applied to all tasks
1500 in the group.
1501
1502 Returns:
1503 ~celery.group: signature that when called will then call all of the
1504 tasks in the group (and return a :class:`GroupResult` instance
1505 that can be used to inspect the state of the group).
1506 """
1507
1508 tasks = getitem_property('kwargs.tasks', 'Tasks in group.')
1509
1510 @classmethod
1511 def from_dict(cls, d, app=None):
1512 """Create a group signature from a dictionary that represents a group.
1513
1514 Example:
1515 >>> group_dict = {
1516 "task": "celery.group",
1517 "args": [],
1518 "kwargs": {
1519 "tasks": [
1520 {
1521 "task": "add",
1522 "args": [
1523 1,
1524 2
1525 ],
1526 "kwargs": {},
1527 "options": {},
1528 "subtask_type": None,
1529 "immutable": False
1530 },
1531 {
1532 "task": "add",
1533 "args": [
1534 3,
1535 4

Calls 1

getitem_propertyClass · 0.90