summaryrefslogtreecommitdiffstats
path: root/meta/classes-global/buildstats.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-01 13:20:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-03 18:01:29 +0000
commit2bd54942917d8ed51d85cc291162002eac7bd133 (patch)
treef9e870310bcb29528a663242bf2e40a4d0bafbe4 /meta/classes-global/buildstats.bbclass
parent44f2059a93f1af2e749b26705ec90b47b1cea45d (diff)
downloadpoky-2bd54942917d8ed51d85cc291162002eac7bd133.tar.gz
buildstats: Avoid rare UnboundLocalError
In rare cases BUILDNAME can seemingly be None outside of heartbeat events which leads to UnboundLocalErrors as bsdir and taskdir aren't defined. Skip the code in these cases rather than generate tracebacks which cause bitbake server to exit. (From OE-Core rev: 0f74d804ba0daf7e8bd6481597740b9d89821414) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-global/buildstats.bbclass')
-rw-r--r--meta/classes-global/buildstats.bbclass15
1 files changed, 9 insertions, 6 deletions
diff --git a/meta/classes-global/buildstats.bbclass b/meta/classes-global/buildstats.bbclass
index 8a50bede5f..fe64789e10 100644
--- a/meta/classes-global/buildstats.bbclass
+++ b/meta/classes-global/buildstats.bbclass
@@ -188,14 +188,17 @@ python run_buildstats () {
188 # bitbake fires HeartbeatEvent even before a build has been 188 # bitbake fires HeartbeatEvent even before a build has been
189 # triggered, causing BUILDNAME to be None 189 # triggered, causing BUILDNAME to be None
190 ######################################################################## 190 ########################################################################
191 if bn is not None: 191 if bn is None:
192 bsdir = os.path.join(d.getVar('BUILDSTATS_BASE'), bn) 192 return
193 taskdir = os.path.join(bsdir, d.getVar('PF')) 193
194 if isinstance(e, bb.event.HeartbeatEvent) and bb.utils.to_boolean(d.getVar("BB_LOG_HOST_STAT_ON_INTERVAL")): 194 bsdir = os.path.join(d.getVar('BUILDSTATS_BASE'), bn)
195 taskdir = os.path.join(bsdir, d.getVar('PF'))
196 if isinstance(e, bb.event.HeartbeatEvent):
197 if bb.utils.to_boolean(d.getVar("BB_LOG_HOST_STAT_ON_INTERVAL")):
195 bb.utils.mkdirhier(bsdir) 198 bb.utils.mkdirhier(bsdir)
196 write_host_data(os.path.join(bsdir, "host_stats_interval"), e, d, "interval") 199 write_host_data(os.path.join(bsdir, "host_stats_interval"), e, d, "interval")
197 200
198 if isinstance(e, bb.event.BuildStarted): 201 elif isinstance(e, bb.event.BuildStarted):
199 ######################################################################## 202 ########################################################################
200 # If the kernel was not configured to provide I/O statistics, issue 203 # If the kernel was not configured to provide I/O statistics, issue
201 # a one time warning. 204 # a one time warning.
@@ -234,7 +237,7 @@ python run_buildstats () {
234 if cpu: 237 if cpu:
235 f.write("CPU usage: %0.1f%% \n" % cpu) 238 f.write("CPU usage: %0.1f%% \n" % cpu)
236 239
237 if isinstance(e, bb.build.TaskStarted): 240 elif isinstance(e, bb.build.TaskStarted):
238 set_timedata("__timedata_task", d, e.time) 241 set_timedata("__timedata_task", d, e.time)
239 bb.utils.mkdirhier(taskdir) 242 bb.utils.mkdirhier(taskdir)
240 # write into the task event file the name and start time 243 # write into the task event file the name and start time