[bitbake-devel] [PATCH] event: Improve exception handling

Richard Purdie richard.purdie at linuxfoundation.org
Tue Mar 10 14:27:48 UTC 2015


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 <richard.purdie at linuxfoundation.org>

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index fec6a05..62a8f4f 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -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
 





More information about the bitbake-devel mailing list