MCPcopy
hub / github.com/celery/celery / handle_retry

Method handle_retry

celery/app/trace.py:212–240  ·  view source on GitHub ↗

Handle retry exception.

(self, task, req, store_errors=True, **kwargs)

Source from the content-addressed store, hash-verified

210 self._log_error(task, req, ExceptionInfo())
211
212 def handle_retry(self, task, req, store_errors=True, **kwargs):
213 """Handle retry exception."""
214 # the exception raised is the Retry semi-predicate,
215 # and it's exc' attribute is the original exception raised (if any).
216 type_, _, tb = sys.exc_info()
217 einfo = None
218 try:
219 reason = self.retval
220 einfo = ExceptionInfo((type_, reason, tb))
221 if store_errors:
222 task.backend.mark_as_retry(
223 req.id, reason.exc, einfo.traceback, request=req,
224 )
225 task.on_retry(reason.exc, req.id, req.args, req.kwargs, einfo)
226 signals.task_retry.send(sender=task, request=req,
227 reason=reason, einfo=einfo)
228 info(LOG_RETRY, {
229 'id': req.id,
230 'name': get_task_name(req, task.name),
231 'exc': str(reason),
232 })
233 # MEMORY LEAK FIX: Clear traceback frames to prevent memory retention (Issue #8882)
234 traceback_clear(einfo.exception)
235 return einfo
236 finally:
237 # MEMORY LEAK FIX: Clean up direct traceback reference to prevent
238 # retention of frame objects and their local variables (Issue #8882)
239 if tb is not None:
240 del tb
241
242 def handle_failure(self, task, req, store_errors=True, call_errbacks=True):
243 """Handle exception."""

Calls 6

infoFunction · 0.85
get_task_nameFunction · 0.85
traceback_clearFunction · 0.85
mark_as_retryMethod · 0.80
on_retryMethod · 0.45
sendMethod · 0.45

Tested by 1