diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-03 22:01:25 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-05 13:27:55 +0000 |
commit | e427eafa1bb04008d12100ccc5c862122bba53e0 (patch) | |
tree | 07f2866d54ccde5054217c45eed9dce5e61bd839 /lib/bb/build.py | |
parent | 3aad9978be2a40d4c535a5ae092f374ba2a5f627 (diff) | |
download | bitbake-e427eafa1bb04008d12100ccc5c862122bba53e0.tar.gz |
knotty/uihelper: Switch from pids to tids for Task event management
We've seen cases where a task can execute with a given pid, complete
and a new task can start using the same pid before the UI handler has
had time to adapt.
Traceback (most recent call last):
File "/home/pokybuild/yocto-worker/qemux86-alt/build/bitbake/lib/bb/ui/knotty.py", line 484, in main
helper.eventHandler(event)
File "/home/pokybuild/yocto-worker/qemux86-alt/build/bitbake/lib/bb/ui/uihelper.py", line 30, in eventHandler
del self.running_tasks[event.pid]
KeyError: 13490
This means using pids to match up events on the UI side is a bad
idea. Change the code to use task ids instead. There is a small
amount of fuzzy matching for the progress information since there
is no task information there and we don't want the overhead of a task
ID in every event, however since pid reuse is unlikely, we can live
with a progress bar not quite working properly in a corner case like
this.
[YOCTO #13667]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/build.py')
-rw-r--r-- | lib/bb/build.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py index 30a2ba236..3d9cc10c8 100644 --- a/lib/bb/build.py +++ b/lib/bb/build.py @@ -57,8 +57,9 @@ builtins['os'] = os class TaskBase(event.Event): """Base class for task events""" - def __init__(self, t, logfile, d): + def __init__(self, t, fn, logfile, d): self._task = t + self._fn = fn self._package = d.getVar("PF") self._mc = d.getVar("BB_CURRENT_MC") self.taskfile = d.getVar("FILE") @@ -81,8 +82,8 @@ class TaskBase(event.Event): class TaskStarted(TaskBase): """Task execution started""" - def __init__(self, t, logfile, taskflags, d): - super(TaskStarted, self).__init__(t, logfile, d) + def __init__(self, t, fn, logfile, taskflags, d): + super(TaskStarted, self).__init__(t, fn, logfile, d) self.taskflags = taskflags class TaskSucceeded(TaskBase): @@ -91,9 +92,9 @@ class TaskSucceeded(TaskBase): class TaskFailed(TaskBase): """Task execution failed""" - def __init__(self, task, logfile, metadata, errprinted = False): + def __init__(self, task, fn, logfile, metadata, errprinted = False): self.errprinted = errprinted - super(TaskFailed, self).__init__(task, logfile, metadata) + super(TaskFailed, self).__init__(task, fn, logfile, metadata) class TaskFailedSilent(TaskBase): """Task execution failed (silently)""" @@ -103,8 +104,8 @@ class TaskFailedSilent(TaskBase): class TaskInvalid(TaskBase): - def __init__(self, task, metadata): - super(TaskInvalid, self).__init__(task, None, metadata) + def __init__(self, task, fn, metadata): + super(TaskInvalid, self).__init__(task, fn, None, metadata) self._message = "No such task '%s'" % task class TaskProgress(event.Event): @@ -572,7 +573,7 @@ def _exec_task(fn, task, d, quieterr): try: try: - event.fire(TaskStarted(task, logfn, flags, localdata), localdata) + event.fire(TaskStarted(task, fn, logfn, flags, localdata), localdata) except (bb.BBHandledException, SystemExit): return 1 @@ -583,15 +584,15 @@ def _exec_task(fn, task, d, quieterr): for func in (postfuncs or '').split(): exec_func(func, localdata) except bb.BBHandledException: - event.fire(TaskFailed(task, logfn, localdata, True), localdata) + event.fire(TaskFailed(task, fn, logfn, localdata, True), localdata) return 1 except Exception as exc: if quieterr: - event.fire(TaskFailedSilent(task, logfn, localdata), localdata) + event.fire(TaskFailedSilent(task, fn, logfn, localdata), localdata) else: errprinted = errchk.triggered logger.error(str(exc)) - event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata) + event.fire(TaskFailed(task, fn, logfn, localdata, errprinted), localdata) return 1 finally: sys.stdout.flush() @@ -614,7 +615,7 @@ def _exec_task(fn, task, d, quieterr): logger.debug(2, "Zero size logfn %s, removing", logfn) bb.utils.remove(logfn) bb.utils.remove(loglink) - event.fire(TaskSucceeded(task, logfn, localdata), localdata) + event.fire(TaskSucceeded(task, fn, logfn, localdata), localdata) if not localdata.getVarFlag(task, 'nostamp', False) and not localdata.getVarFlag(task, 'selfstamp', False): make_stamp(task, localdata) |