aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-23 11:50:25 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-23 12:26:35 +0100
commit8966b43761500e0505333d8c9a3f0f2c3dbe7559 (patch)
treef2560b801848de2ab5dff32cf02d497c1a89dc73
parent36f6dce1b21a7d9f39a73f081395c71045960318 (diff)
downloadbitbake-8966b43761500e0505333d8c9a3f0f2c3dbe7559.tar.gz
build: Ensure python stdout/stderr is logged correctly
Currently we see things like: Log data follows: | DEBUG: Executing python function do_pythontest_exit | DEBUG: Python function do_pythontest_exit finished | ERROR: 1 | This is python stdout Whilst after the change we see things like: Log data follows: | DEBUG: Executing python function do_pythontest_exit | This is python stdout | DEBUG: Python function do_pythontest_exit finished | ERROR: 1 since the output is now correctly mixed with the log messages. In some cases the logging tests indicate the output is being lost entirely which is bad for debugging and makes things rather confusing. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/build.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index c2479dd16..18586c276 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -298,6 +298,10 @@ def exec_func_python(func, d, runfile, cwd=None):
comp = utils.better_compile(code, func, "exec_func_python() autogenerated")
utils.better_exec(comp, {"d": d}, code, "exec_func_python() autogenerated")
finally:
+ # We want any stdout/stderr to be printed before any other log messages to make debugging
+ # more accurate. In some cases we seem to lose stdout/stderr entirely in logging tests without this.
+ sys.stdout.flush()
+ sys.stderr.flush()
bb.debug(2, "Python function %s finished" % func)
if cwd and olddir: