event: Improve exception handling
PATCH 1/1 event: Improve exception handling
Currently, if an exception occurs during an event handler execution, things can get messy and in many cases the system will loop indefinitely, particularly if its being triggered through idle handler code.
This patch changes things so that unhandled exceptions print an error onto the console/logs, then continue, rather than raising an exception into "higher" level code which simply can't handle it.
In particular this is more in keeping with the meaning of "Handled" exceptions. Real world error cases triggering these code paths were much more stable after these changes than before (which just looped infinitely printing exceptions).
Signed-off-by Richard Purdie <[email protected]>
bitbake/lib/bb/event.py +4 -4
@@ -74,17 +74,17 @@ def execute_handler(name, handler, event, d): event.data = d try: ret = handler(event) - except (bb.parse.SkipRecipe, bb.BBHandledException): + except bb.parse.SkipRecipe: raise + except bb.BBHandledException: + pass except Exception: etype, value, tb = sys.exc_info() logger.error("Execution of event handler '%s' failed" % name, exc_info=(etype, value, tb.tb_next)) - raise except SystemExit as exc: if exc.code != 0: - logger.error("Execution of event handler '%s' failed" % name) - raise + logger.error("Execution of event handler '%s' failed (exit code %s)" % (name, exc.code)) finally: del event.data