uihelper: Fix exception when TaskStarted event handler breaks
PATCH 1/3 uihelper: Fix exception when TaskStarted event handler breaks
If there is an exception in a TaskStarted event handler, we can get a still get a TaskFailed event which will trigger a second exception. Since our TaskStarted code may not have run. Avoid that second exception from an undefined dict key.
--- lib/bb/ui/uihelper.py | 3 +++ 1 file changed, 3 insertions(+)
lib/bb/ui/uihelper.py +3 -0
@@ -25,6 +25,9 @@ class BBUIHelper: # PIDs are a bad idea as they can be reused before we process all UI events. # We maintain a 'fuzzy' match for TaskProgress since there is no other way to match def removetid(pid, tid): + if tid not in self.running_tasks: + # This is possible if you have an exception during a TaskStarted handler + return del self.running_tasks[tid] if self.pidmap[pid] == tid: del self.pidmap[pid]
PATCH 2/3 cache: Add support for BB_CACHE_EXTRAVARS
This allows the metadata to specify that some variables should be cached on a per recipe basis.
This is useful for example to allow RECIPE_HOSTTOOLS in OE-Core to error up front in a build if tools are missing rather than the build failing part way through.
--- lib/bb/cache.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
lib/bb/cache.py +14 -1
@@ -27,7 +27,7 @@ import shutil logger = logging.getLogger("BitBake.Cache") -__cache_version__ = "156" +__cache_version__ = "157" def getCacheFile(path, filename, mc, data_hash): mcspec = ''
@@ -131,6 +131,14 @@ class CoreRecipeInfo(RecipeInfoCommon): self.fakerootnoenv = self.getvar('FAKEROOTNOENV', metadata) self.extradepsfunc = self.getvar('calculate_extra_depends', metadata) + self.extravars = self.listvar('BB_CACHE_EXTRAVARS', metadata) + if self.extravars: + for var in self.extravars: + val = self.getvar(var, metadata) + if val: + bb.warn(str(val)) + setattr(self, var, self.getvar(var, metadata)) + @classmethod def init_cacheData(cls, cachedata): # CacheData in Core RecipeInfo Class
@@ -168,6 +176,8 @@ class CoreRecipeInfo(RecipeInfoCommon): cachedata.fakerootlogs = {} cachedata.extradepsfunc = {} + cachedata.extravars = {} + def add_cacheData(self, cachedata, fn): cachedata.task_deps[fn] = self.task_deps cachedata.pkg_fn[fn] = self.pn
@@ -237,6 +247,9 @@ class CoreRecipeInfo(RecipeInfoCommon): cachedata.fakerootlogs[fn] = self.fakerootlogs cachedata.extradepsfunc[fn] = self.extradepsfunc + cachedata.extravars[fn] = {} + for var in self.extravars: + cachedata.extravars[fn][var] = getattr(self, var) class SiggenRecipeInfo(RecipeInfoCommon): __slots__ = ()
PATCH 3/3 runqueue: Add a RecipeCheckEvent
In reply to Richard PurdieThis event triggers at the start of a build, once the task graph is known and provides a list of the recipes which will execure alongside any custom variable data that was requested to be cached in BB_CACHE_EXTRAVARS.
--- lib/bb/runqueue.py | 11 +++++++++++ 1 file changed, 11 insertions(+)
lib/bb/runqueue.py +11 -0
@@ -1608,6 +1608,8 @@ class RunQueue: ('bb.event.HeartbeatEvent',), data=self.cfgData) self.dm_event_handler_registered = True + bb.event.fire(RecipeCheckEvent(self.rqdata), self.cooker.data) + self.rqdata.init_progress_reporter.next_stage() self.rqexe = RunQueueExecute(self)
@@ -3316,6 +3318,15 @@ class PSIEvent(bb.event.Event): self.pressure_state = pressure_state self.pressure_values = pressure_values +class RecipeCheckEvent(bb.event.Event): + def __init__(self, rqdata): + super().__init__() + recipedata = {} + for tid in rqdata.runtaskentries: + (mc, fn, taskname, taskfn) = split_tid_mcfn(tid) + recipedata[taskfn] = rqdata.dataCaches[mc].extravars[taskfn] + self.recipedata = recipedata + class runQueuePipe(): """ Abstraction for a pipe between a worker thread and the server