diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index ad031cc702..b10431c4ae 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -298,6 +298,10 @@ def exec_func_python(func, d, runfile, cwd=None): comp = utils.better_compile(code, func, "exec_python_func() autogenerated") utils.better_exec(comp, {"d": d}, code, "exec_python_func() 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: