]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
event/msg: Pass formatted exceptions
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 12 May 2016 07:05:32 +0000 (08:05 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 12 May 2016 22:01:03 +0000 (23:01 +0100)
python3 can't cope with the previous approach we were using to pass
exceptions through the RPC. Avoid this by creating a formatted exception
on the sender side.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/event.py
lib/bb/msg.py

index 5a03a31f4368d6f68512d95727a1d323ba255cef..29b14f6c325fa3d4043d840c08cb7341727ce6db 100644 (file)
@@ -610,8 +610,9 @@ class LogHandler(logging.Handler):
             if hasattr(tb, 'tb_next'):
                 tb = list(bb.exceptions.extract_traceback(tb, context=3))
             # Need to turn the value into something the logging system can pickle
-            value = str(value)
             record.bb_exc_info = (etype, value, tb)
+            record.bb_exc_formatted = bb.exceptions.format_exception(etype, value, tb, limit=5)
+            value = str(value)
             record.exc_info = None
         fire(record, None)
 
index 786b5aef400c567be41ec90c79f020350952319f..6fdd1f52a082ef7f8996a29000a91124fd024aa7 100644 (file)
@@ -90,8 +90,9 @@ class BBLogFormatter(logging.Formatter):
             if self.color_enabled:
                 record = self.colorize(record)
             msg = logging.Formatter.format(self, record)
-
-        if hasattr(record, 'bb_exc_info'):
+        if hasattr(record, 'bb_exc_formatted'):
+            msg += '\n' + ''.join(record.bb_exc_formatted)
+        elif hasattr(record, 'bb_exc_info'):
             etype, value, tb = record.bb_exc_info
             formatted = bb.exceptions.format_exception(etype, value, tb, limit=5)
             msg += '\n' + ''.join(formatted)