ashb commented on code in PR #23121:
URL: https://github.com/apache/airflow/pull/23121#discussion_r854546694
##########
airflow/models/taskinstance.py:
##########
@@ -1845,33 +1838,21 @@ def _handle_reschedule(
session.commit()
self.log.info('Rescheduling task, marking task as UP_FOR_RESCHEDULE')
- def get_truncated_error_traceback(self, error: BaseException) ->
Optional[TracebackType]:
+ @staticmethod
+ def get_truncated_error_traceback(error: BaseException, truncate_to:
Callable) -> Optional[TracebackType]:
"""
- Returns truncated error traceback.
-
- This method returns traceback of the error truncated to the
- frame saved by earlier try/except along the way. If the frame
- is found, the traceback will be truncated to below the frame.
+ Truncates the traceback of an exception to the first frame called from
within a given function
:param error: exception to get traceback from
- :return: traceback to print
+ :param truncate_to: Function to truncate TB to. Must have a
``__code__`` attribute
+
+ :meta private:
"""
tb = error.__traceback__
- try:
- execution_frame = _TASK_EXECUTION_FRAME_LOCAL_STORAGE.frame
- except AttributeError:
- self.log.warning(
- "We expected to get frame set in local storage but it was not."
- " Please report this as an issue with full logs"
- " at https://github.com/apache/airflow/issues/new",
- exc_info=True,
- )
- return tb
- _TASK_EXECUTION_FRAME_LOCAL_STORAGE.frame = None
+ code = truncate_to.__func__.__code__ # type: ignore[attr-defined]
Review Comment:
We are comparing with `is` -- so it is comparing is it the exact same object
-- no `__eq__` function or equivalent is checked, so its as quick as it can be.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]