summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-04-04 11:31:39 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-06 15:48:22 +0100
commit37cb4cc02b2e2b6c338c5943747e0a1ef15176b3 (patch)
tree454bba6a6c191c834ff26903137e4ba130873b18 /bitbake
parent8cf28d706b7e70f5835b1bd4da058ec64f520c6c (diff)
downloadpoky-37cb4cc02b2e2b6c338c5943747e0a1ef15176b3.tar.gz
poky-37cb4cc02b2e2b6c338c5943747e0a1ef15176b3.tar.bz2
poky-37cb4cc02b2e2b6c338c5943747e0a1ef15176b3.zip
event: improve output when eventhandler exec fails
- Name the event handler by its actual name, so the traceback shows it rather than 'tmpHandler'. - Rather than immediately aborting when encountering an event handler error, display an error message and try to continue. - Show a traceback for ordinary exceptions, skipping the first entry in the traceback, so it only shows the useful information. - Show an error, but no traceback, for SystemExit with a code other than 0. - For for SystemExit with a code of 0, simply continue silently. (Bitbake rev: faf682dfc23b7ef2ece04f7d50f9741224bb3bb0) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/event.py42
1 files changed, 31 insertions, 11 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 9a07ed5c0a..ec6446d64c 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -37,6 +37,8 @@ import bb.utils
worker_pid = 0
worker_pipe = None
+logger = logging.getLogger('BitBake.Event')
+
class Event(object):
"""Base class for events"""
@@ -58,18 +60,35 @@ _ui_handler_seq = 0
bb.utils._context["NotHandled"] = NotHandled
bb.utils._context["Handled"] = Handled
+def execute_handler(name, handler, event, d):
+ event.data = d
+ try:
+ ret = handler(event)
+ 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
+ finally:
+ del event.data
+
+ if ret is not None:
+ warnings.warn("Using Handled/NotHandled in event handlers is deprecated",
+ DeprecationWarning, stacklevel = 2)
+
def fire_class_handlers(event, d):
if isinstance(event, logging.LogRecord):
return
- for handler in _handlers.itervalues():
- event.data = d
- ret = handler(event)
- if ret is not None:
- warnings.warn("Using Handled/NotHandled in event handlers is deprecated",
- DeprecationWarning, stacklevel = 2)
-
- del event.data
+ for name, handler in _handlers.iteritems():
+ try:
+ execute_handler(name, handler, event, d)
+ except BaseException:
+ continue
ui_queue = []
@atexit.register
@@ -141,11 +160,12 @@ def register(name, handler):
if handler is not None:
# handle string containing python code
if isinstance(handler, basestring):
- tmp = "def tmpHandler(e):\n%s" % handler
- comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode")
+ tmp = "def %s(e):\n%s" % (name, handler)
+ comp = bb.utils.better_compile(tmp, "%s(e)" % name,
+ "bb.event._registerCode")
env = {}
bb.utils.simple_exec(comp, env)
- func = bb.utils.better_eval("tmpHandler", env)
+ func = bb.utils.better_eval(name, env)
_handlers[name] = func
else:
_handlers[name] = handler