All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] process: Flush server stdout/stderr before reporting failure
@ 2018-09-02  8:43 Jan Kiszka
  2018-09-04 12:15 ` Richard Purdie
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2018-09-02  8:43 UTC (permalink / raw)
  To: bitbake-devel

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@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):
         try:
             self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
             writer.send("ready")
-        except:
+        except (Exception, SystemExit) as e:
+            if type(e) != SystemExit:
+                traceback.print_exc()
+            sys.stdout.flush()
+            sys.stderr.flush()
             writer.send("fail")
             raise
         finally:
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-07  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-02  8:43 [PATCH] process: Flush server stdout/stderr before reporting failure Jan Kiszka
2018-09-04 12:15 ` Richard Purdie
2018-09-04 12:34   ` Richard Purdie
2018-09-04 13:09     ` Jan Kiszka
2018-09-05  0:14       ` richard.purdie
2018-09-07  9:48         ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.