MCPcopy
hub / github.com/celery/celery / Signature

Class Signature

celery/canvas.py:232–871  ·  view source on GitHub ↗

Task Signature. Class that wraps the arguments and execution options for a single task invocation. Used as the parts in a :class:`group` and other constructs, or to pass tasks around as callbacks while being compatible with serializers with a strict type subset. Signatures

Source from the content-addressed store, hash-verified

230
231@abstract.CallableSignature.register
232class Signature(dict):
233 """Task Signature.
234
235 Class that wraps the arguments and execution options
236 for a single task invocation.
237
238 Used as the parts in a :class:`group` and other constructs,
239 or to pass tasks around as callbacks while being compatible
240 with serializers with a strict type subset.
241
242 Signatures can also be created from tasks:
243
244 - Using the ``.signature()`` method that has the same signature
245 as ``Task.apply_async``:
246
247 .. code-block:: pycon
248
249 >>> add.signature(args=(1,), kwargs={'kw': 2}, options={})
250
251 - or the ``.s()`` shortcut that works for star arguments:
252
253 .. code-block:: pycon
254
255 >>> add.s(1, kw=2)
256
257 - the ``.s()`` shortcut does not allow you to specify execution options
258 but there's a chaining `.set` method that returns the signature:
259
260 .. code-block:: pycon
261
262 >>> add.s(2, 2).set(countdown=10).set(expires=30).delay()
263
264 Note:
265 You should use :func:`~celery.signature` to create new signatures.
266 The ``Signature`` class is the type returned by that function and
267 should be used for ``isinstance`` checks for signatures.
268
269 See Also:
270 :ref:`guide-canvas` for the complete guide.
271
272 Arguments:
273 task (Union[Type[celery.app.task.Task], str]): Either a task
274 class/instance, or the name of a task.
275 args (Tuple): Positional arguments to apply.
276 kwargs (Dict): Keyword arguments to apply.
277 options (Dict): Additional options to :meth:`Task.apply_async`.
278
279 Note:
280 If the first argument is a :class:`dict`, the other
281 arguments will be ignored and the values in the dict will be used
282 instead::
283
284 >>> s = signature('tasks.add', args=(2, 2))
285 >>> signature(s)
286 {'task': 'tasks.add', args=(2, 2), kwargs={}, options={}}
287 """
288
289 TYPES = {}

Callers 10

chord_contextMethod · 0.90
test_canvas.pyFile · 0.90
test_callMethod · 0.90
test_link_on_scalarMethod · 0.90
test_jsonMethod · 0.90
test_reduceMethod · 0.90
test_replaceMethod · 0.90
test_setMethod · 0.90
from_dictMethod · 0.85
signatureFunction · 0.85

Calls 1

getitem_propertyClass · 0.90

Tested by 7

chord_contextMethod · 0.72
test_callMethod · 0.72
test_link_on_scalarMethod · 0.72
test_jsonMethod · 0.72
test_reduceMethod · 0.72
test_replaceMethod · 0.72
test_setMethod · 0.72