MCPcopy Create free account
hub / github.com/celery/celery / trace_task

Function trace_task

celery/app/trace.py:454–697  ·  view source on GitHub ↗
(uuid, args, kwargs, request=None)

Source from the content-addressed store, hash-verified

452 )
453
454 def trace_task(uuid, args, kwargs, request=None):
455 # R - is the possibly prepared return value.
456 # I - is the Info object.
457 # T - runtime
458 # Rstr - textual representation of return value
459 # retval - is the always unmodified return value.
460 # state - is the resulting task state.
461
462 # This function is very long because we've unrolled all the calls
463 # for performance reasons, and because the function is so long
464 # we want the main variables (I, and R) to stand out visually from the
465 # the rest of the variables, so breaking PEP8 is worth it ;)
466 R = I = T = Rstr = retval = state = None
467 task_request = None
468 time_start = monotonic()
469 try:
470 try:
471 kwargs.items
472 except AttributeError:
473 raise InvalidTaskError(
474 'Task keyword arguments is not a mapping')
475
476 task_request = Context(request or {}, args=args,
477 called_directly=False, kwargs=kwargs)
478
479 ignore_result = get_actual_ignore_result(task, task_request)
480 track_started = not eager and (task.track_started and not ignore_result)
481 # #6476
482 if eager and not ignore_result and task.store_eager_result:
483 publish_result = True
484 else:
485 publish_result = not eager and not ignore_result
486
487 redelivered = (task_request.delivery_info
488 and task_request.delivery_info.get('redelivered', False))
489 if deduplicate_successful_tasks and redelivered:
490 if task_request.id in successful_requests:
491 return trace_ok_t(R, I, T, Rstr)
492 r = AsyncResult(task_request.id, app=app)
493
494 try:
495 state = r.state
496 except BackendGetMetaError:
497 pass
498 else:
499 if state == SUCCESS:
500 info(LOG_IGNORED, {
501 'id': task_request.id,
502 'name': get_task_name(task_request, name),
503 'description': 'Task already completed successfully.'
504 })
505 _root_id = task_request.root_id or uuid
506 _priority = task_request.delivery_info.get('priority') if \
507 inherit_parent_priority else None
508 try:
509 _meta = r._get_task_meta()
510 stored_retval = _meta.get('result')
511 # Children are populated by mark_as_done on the

Calls 15

getMethod · 0.95
_get_task_metaMethod · 0.95
InvalidTaskErrorClass · 0.90
ContextClass · 0.90
get_actual_ignore_resultFunction · 0.90
AsyncResultClass · 0.90
RejectClass · 0.90
safereprFunction · 0.90
infoFunction · 0.85
get_task_nameFunction · 0.85
funFunction · 0.85