MCPcopy
hub / github.com/celery/celery / maybe_unroll_group

Function maybe_unroll_group

celery/canvas.py:42–57  ·  view source on GitHub ↗

Unroll group with only one member. This allows treating a group of a single task as if it was a single task without pre-knowledge.

(group)

Source from the content-addressed store, hash-verified

40
41
42def maybe_unroll_group(group):
43 """Unroll group with only one member.
44 This allows treating a group of a single task as if it
45 was a single task without pre-knowledge."""
46 # Issue #1656
47 try:
48 size = len(group.tasks)
49 except TypeError:
50 try:
51 size = group.tasks.__length_hint__()
52 except (AttributeError, TypeError):
53 return group
54 else:
55 return list(group.tasks)[0] if size == 1 else group
56 else:
57 return group.tasks[0] if size == 1 else group
58
59
60def task_name_from(task):

Callers 5

__or__Method · 0.85
__or__Method · 0.85
prepare_stepsMethod · 0.85
__or__Method · 0.85

Calls 1

__length_hint__Method · 0.45

Tested by 1