[bitbake-devel] [PATCH] process: Flush server stdout/stderr before reporting failure

Jan Kiszka jan.kiszka at siemens.com
Sun Sep 2 08:43:27 UTC 2018

We need to print exceptions and flush output channels before telling the
client that the server failed. Otherwise the daemon log file may still
be empty when the client opens it for printing.

This fixes error reporting when the output is redirected to a pipe, e.g.
"bitbake target | cat" with a syntax error in a recipes or config file.
That's specifically annoying when bitbake is under the control of a
frontend process such as kas.

Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
 lib/bb/server/process.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 9e5e709f..bcc4eb40 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -29,6 +29,7 @@ import array
 import os
 import sys
 import time
+import traceback
 import select
 import socket
 import subprocess
@@ -435,7 +436,11 @@ class BitBakeServer(object):
             self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
-        except:
+        except (Exception, SystemExit) as e:
+            if type(e) != SystemExit:
+                traceback.print_exc()
+            sys.stdout.flush()
+            sys.stderr.flush()

More information about the bitbake-devel mailing list