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

Method chord_error_from_stack

celery/backends/base.py:464–504  ·  view source on GitHub ↗
(self, callback, exc=None)

Source from the content-addressed store, hash-verified

462 traceback=traceback, request=request)
463
464 def chord_error_from_stack(self, callback, exc=None):
465 app = self.app
466 if exc is None:
467 exc = sys.exc_info()[1]
468
469 try:
470 backend = app._tasks[callback.task].backend
471 except KeyError:
472 backend = self
473
474 # Handle group callbacks specially to prevent hanging body tasks
475 if isinstance(callback, group):
476 exception_info = self._handle_group_chord_error(group_callback=callback, backend=backend, exc=exc)
477 backend._fail_chain(callback.options.get("chain"), exc)
478 return exception_info
479
480 # Generate an ID if missing so the error can be stored.
481 callback_id = callback.id
482 if not callback_id:
483 from kombu.utils.uuid import uuid
484 callback_id = callback.options['task_id'] = uuid()
485
486 # We have to make a fake request since either the callback failed or
487 # we're pretending it did since we don't have information about the
488 # chord part(s) which failed. This request is constructed as a best
489 # effort for new style errbacks and may be slightly misleading about
490 # what really went wrong, but at least we call them!
491 fake_request = _create_fake_task_request(
492 task_id=callback.options.get("task_id"),
493 errbacks=callback.options.get("link_error", []),
494 **callback
495 )
496 try:
497 self._call_task_errbacks(fake_request, exc, None)
498 except Exception as eb_exc: # pylint: disable=broad-except
499 exc = eb_exc
500 exception_info = backend.fail_from_current_stack(callback_id, exc=exc)
501 else:
502 exception_info = backend.fail_from_current_stack(callback_id, exc=exc)
503 backend._fail_chain(callback.options.get("chain"), exc)
504 return exception_info
505
506 def _handle_group_chord_error(self, group_callback, backend, exc=None):
507 """Handle chord errors when the callback is a group.

Calls 6

_call_task_errbacksMethod · 0.95
_fail_chainMethod · 0.80
getMethod · 0.45