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