From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mx.groups.io with SMTP id smtpd.web11.3231.1632396536922815645 for ; Thu, 23 Sep 2021 04:28:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=DIK+/Pa6; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.52, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f52.google.com with SMTP id i24so285349wrc.9 for ; Thu, 23 Sep 2021 04:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5qle6vaIAWyUrKosz4esRM7nUCQp/FW1ZqUyDw3sfwM=; b=DIK+/Pa6Kt9UbjWWfbD2aLZZD8X5OayCVExQCfDKkHv633JUNDtmmIKq+qenDK7zzz azf9huykMFdsbuyKtN+c0zCtY11VDUqdKvs+VkE6j4QwsqKwaj8Q8kD1Az4gnJ7J91az ycai1osyXD/MRWcLi7RYIn9PRAkVJ5Dt3uj00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5qle6vaIAWyUrKosz4esRM7nUCQp/FW1ZqUyDw3sfwM=; b=UQkYATVls6g8R749FRbcNtJn7mqkd2wWAA1nGNYqnawCz7FeusSMou2Euy1SU1F4u2 LGrEqk+nr31Y+cGxvFQ1snL14LMQ3A+GV139MaXw03B3TI06ISLBpqtjqwJofHuo5z2e LBJwdSd+SVPcIrE3JV2XBDAosMeftVVIZBI/zxTJbn8B9GxB0c3zhNGTDqwnTdDYnmhK tVIvbQqLU/IDHu8wJNCr+8ynEU50OURnWMIL02f0d4/mVhIdrwqvdfyUZy3D/ozTLakI +YhNJObdpY+A9+rbyGeln9Tm+mKiPgAv6A3YctMm8jqWonQAVdS2MBC52ud10jEu3Rc7 Kzlg== X-Gm-Message-State: AOAM533fnvfkbxkCy/ZFT61+LMdCmq/2beEpDoH/k9zxDfJrl08WM1jQ /1CHzK2LglMiJWhQw3ZNt5AnCpVEyr65bI87 X-Google-Smtp-Source: ABdhPJzl+ZT1ZPN+2AN/J7lCCZ4G0pukwoGd8Pt+PT1OnfnYIPHxPz/Fn/ZfV1KWkWlwqrTPQeMTPA== X-Received: by 2002:a05:600c:2046:: with SMTP id p6mr3938236wmg.132.1632396535031; Thu, 23 Sep 2021 04:28:55 -0700 (PDT) Return-Path: Received: from hex.int.rpsys.net ([2001:8b0:aba:5f3c:3a36:9e9a:ccb5:f067]) by smtp.gmail.com with ESMTPSA id 5sm5177382wmb.37.2021.09.23.04.28.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 04:28:54 -0700 (PDT) From: "Richard Purdie" To: bitbake-devel@lists.openembedded.org Subject: [PATCH 1/3] build: Ensure python stdout/stderr is logged correctly Date: Thu, 23 Sep 2021 12:28:51 +0100 Message-Id: <20210923112853.1706985-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- lib/bb/build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/bb/build.py b/lib/bb/build.py index c2479dd167..18586c276e 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: -- 2.32.0