r"""Barrier synchronization primitive. A chord consists of a header and a body. The header is a group of tasks that must complete before the callback is called. A chord is essentially a callback for a group of tasks. The body is applied with the return values of all the header
| 1948 | |
| 1949 | @Signature.register_type(name=class="st">"chord") |
| 1950 | class _chord(Signature): |
| 1951 | rclass="st">"""Barrier synchronization primitive. |
| 1952 | |
| 1953 | A chord consists of a header and a body. |
| 1954 | |
| 1955 | The header is a group of tasks that must complete before the callback is |
| 1956 | called. A chord is essentially a callback for a group of tasks. |
| 1957 | |
| 1958 | The body is applied with the return values of all the header |
| 1959 | tasks as a list. |
| 1960 | |
| 1961 | Example: |
| 1962 | |
| 1963 | The chord: |
| 1964 | |
| 1965 | .. code-block:: pycon |
| 1966 | |
| 1967 | >>> res = chord([add.s(2, 2), add.s(4, 4)])(sum_task.s()) |
| 1968 | |
| 1969 | is effectively :math:`\Sigma ((2 + 2) + (4 + 4))`: |
| 1970 | |
| 1971 | .. code-block:: pycon |
| 1972 | |
| 1973 | >>> res.get() |
| 1974 | 12 |
| 1975 | class="st">""" |
| 1976 | |
| 1977 | @classmethod |
| 1978 | def from_dict(cls, d, app=None): |
| 1979 | class="st">"""Create a chord signature from a dictionary that represents a chord. |
| 1980 | |
| 1981 | Example: |
| 1982 | >>> chord_dict = { |
| 1983 | class="st">"task": class="st">"celery.chord", |
| 1984 | class="st">"args": [], |
| 1985 | class="st">"kwargs": { |
| 1986 | class="st">"kwargs": {}, |
| 1987 | class="st">"header": [ |
| 1988 | { |
| 1989 | class="st">"task": class="st">"add", |
| 1990 | class="st">"args": [ |
| 1991 | 1, |
| 1992 | 2 |
| 1993 | ], |
| 1994 | class="st">"kwargs": {}, |
| 1995 | class="st">"options": {}, |
| 1996 | class="st">"subtask_type": None, |
| 1997 | class="st">"immutable": False |
| 1998 | }, |
| 1999 | { |
| 2000 | class="st">"task": class="st">"add", |
| 2001 | class="st">"args": [ |
| 2002 | 3, |
| 2003 | 4 |
| 2004 | ], |
| 2005 | class="st">"kwargs": {}, |
| 2006 | class="st">"options": {}, |
| 2007 | class="st">"subtask_type": None, |
no test coverage detected