MCPcopy
hub / github.com/celery/celery / freeze

Method freeze

celery/canvas.py:472–519  ·  view source on GitHub ↗

Finalize the signature by adding a concrete task id. The task won't be called and you shouldn't call the signature twice after freezing it as that'll result in two task messages using the same task id. The arguments are used to override the signature's headers durin

(self, _id=None, group_id=None, chord=None,
               root_id=None, parent_id=None, group_index=None)

Source from the content-addressed store, hash-verified

470 partial = clone
471
472 def freeze(self, _id=None, group_id=None, chord=None,
473 root_id=None, parent_id=None, group_index=None):
474 """Finalize the signature by adding a concrete task id.
475
476 The task won't be called and you shouldn't call the signature
477 twice after freezing it as that'll result in two task messages
478 using the same task id.
479
480 The arguments are used to override the signature's headers during
481 freezing.
482
483 Arguments:
484 _id (str): Task id to use if it didn't already have one.
485 New UUID is generated if not provided.
486 group_id (str): Group id to use if it didn't already have one.
487 chord (Signature): Chord body when freezing a chord header.
488 root_id (str): Root id to use.
489 parent_id (str): Parent id to use.
490 group_index (int): Group index to use.
491
492 Returns:
493 ~@AsyncResult: promise of future evaluation.
494 """
495 # pylint: disable=redefined-outer-name
496 # XXX chord is also a class in outer scope.
497 opts = self.options
498 try:
499 # if there is already an id for this task, return it
500 tid = opts['task_id']
501 except KeyError:
502 # otherwise, use the _id sent to this function, falling back on a generated UUID
503 tid = opts['task_id'] = _id or uuid()
504 if root_id:
505 opts['root_id'] = root_id
506 if parent_id:
507 opts['parent_id'] = parent_id
508 if 'reply_to' not in opts:
509 # fall back on unique ID for this thread in the app
510 opts['reply_to'] = self.app.thread_oid
511 if group_id and "group_id" not in opts:
512 opts['group_id'] = group_id
513 if chord:
514 opts['chord'] = chord
515 if group_index is not None:
516 opts['group_index'] = group_index
517 # pylint: disable=too-many-function-args
518 # Works on this, as it's a property.
519 return self.AsyncResult(tid)
520
521 _freeze = freeze
522

Callers

nothing calls this directly

Calls 1

AsyncResultMethod · 0.95

Tested by

no test coverage detected