diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-03 22:01:25 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-11 11:06:22 +0000 |
commit | cbb463612535f1e87f1314d2fcf927427e81d449 (patch) | |
tree | 8ed9f497171273d1b5887ba0cb14fbf01e1fa019 /bitbake/lib/bb/build.py | |
parent | afd002529007f1fefc3fc0ed680eb6d4e9494a5d (diff) | |
download | poky-cbb463612535f1e87f1314d2fcf927427e81d449.tar.gz |
bitbake: 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]
(Bitbake rev: a109d034cf4fc059fd5a1e1d03246dac65522dd6)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e427eafa1bb04008d12100ccc5c862122bba53e0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r-- | bitbake/lib/bb/build.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 30a2ba236f..3d9cc10c8c 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -57,8 +57,9 @@ builtins['os'] = os | |||
57 | class TaskBase(event.Event): | 57 | class TaskBase(event.Event): |
58 | """Base class for task events""" | 58 | """Base class for task events""" |
59 | 59 | ||
60 | def __init__(self, t, logfile, d): | 60 | def __init__(self, t, fn, logfile, d): |
61 | self._task = t | 61 | self._task = t |
62 | self._fn = fn | ||
62 | self._package = d.getVar("PF") | 63 | self._package = d.getVar("PF") |
63 | self._mc = d.getVar("BB_CURRENT_MC") | 64 | self._mc = d.getVar("BB_CURRENT_MC") |
64 | self.taskfile = d.getVar("FILE") | 65 | self.taskfile = d.getVar("FILE") |
@@ -81,8 +82,8 @@ class TaskBase(event.Event): | |||
81 | 82 | ||
82 | class TaskStarted(TaskBase): | 83 | class TaskStarted(TaskBase): |
83 | """Task execution started""" | 84 | """Task execution started""" |
84 | def __init__(self, t, logfile, taskflags, d): | 85 | def __init__(self, t, fn, logfile, taskflags, d): |
85 | super(TaskStarted, self).__init__(t, logfile, d) | 86 | super(TaskStarted, self).__init__(t, fn, logfile, d) |
86 | self.taskflags = taskflags | 87 | self.taskflags = taskflags |
87 | 88 | ||
88 | class TaskSucceeded(TaskBase): | 89 | class TaskSucceeded(TaskBase): |
@@ -91,9 +92,9 @@ class TaskSucceeded(TaskBase): | |||
91 | class TaskFailed(TaskBase): | 92 | class TaskFailed(TaskBase): |
92 | """Task execution failed""" | 93 | """Task execution failed""" |
93 | 94 | ||
94 | def __init__(self, task, logfile, metadata, errprinted = False): | 95 | def __init__(self, task, fn, logfile, metadata, errprinted = False): |
95 | self.errprinted = errprinted | 96 | self.errprinted = errprinted |
96 | super(TaskFailed, self).__init__(task, logfile, metadata) | 97 | super(TaskFailed, self).__init__(task, fn, logfile, metadata) |
97 | 98 | ||
98 | class TaskFailedSilent(TaskBase): | 99 | class TaskFailedSilent(TaskBase): |
99 | """Task execution failed (silently)""" | 100 | """Task execution failed (silently)""" |
@@ -103,8 +104,8 @@ class TaskFailedSilent(TaskBase): | |||
103 | 104 | ||
104 | class TaskInvalid(TaskBase): | 105 | class TaskInvalid(TaskBase): |
105 | 106 | ||
106 | def __init__(self, task, metadata): | 107 | def __init__(self, task, fn, metadata): |
107 | super(TaskInvalid, self).__init__(task, None, metadata) | 108 | super(TaskInvalid, self).__init__(task, fn, None, metadata) |
108 | self._message = "No such task '%s'" % task | 109 | self._message = "No such task '%s'" % task |
109 | 110 | ||
110 | class TaskProgress(event.Event): | 111 | class TaskProgress(event.Event): |
@@ -572,7 +573,7 @@ def _exec_task(fn, task, d, quieterr): | |||
572 | 573 | ||
573 | try: | 574 | try: |
574 | try: | 575 | try: |
575 | event.fire(TaskStarted(task, logfn, flags, localdata), localdata) | 576 | event.fire(TaskStarted(task, fn, logfn, flags, localdata), localdata) |
576 | except (bb.BBHandledException, SystemExit): | 577 | except (bb.BBHandledException, SystemExit): |
577 | return 1 | 578 | return 1 |
578 | 579 | ||
@@ -583,15 +584,15 @@ def _exec_task(fn, task, d, quieterr): | |||
583 | for func in (postfuncs or '').split(): | 584 | for func in (postfuncs or '').split(): |
584 | exec_func(func, localdata) | 585 | exec_func(func, localdata) |
585 | except bb.BBHandledException: | 586 | except bb.BBHandledException: |
586 | event.fire(TaskFailed(task, logfn, localdata, True), localdata) | 587 | event.fire(TaskFailed(task, fn, logfn, localdata, True), localdata) |
587 | return 1 | 588 | return 1 |
588 | except Exception as exc: | 589 | except Exception as exc: |
589 | if quieterr: | 590 | if quieterr: |
590 | event.fire(TaskFailedSilent(task, logfn, localdata), localdata) | 591 | event.fire(TaskFailedSilent(task, fn, logfn, localdata), localdata) |
591 | else: | 592 | else: |
592 | errprinted = errchk.triggered | 593 | errprinted = errchk.triggered |
593 | logger.error(str(exc)) | 594 | logger.error(str(exc)) |
594 | event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata) | 595 | event.fire(TaskFailed(task, fn, logfn, localdata, errprinted), localdata) |
595 | return 1 | 596 | return 1 |
596 | finally: | 597 | finally: |
597 | sys.stdout.flush() | 598 | sys.stdout.flush() |
@@ -614,7 +615,7 @@ def _exec_task(fn, task, d, quieterr): | |||
614 | logger.debug(2, "Zero size logfn %s, removing", logfn) | 615 | logger.debug(2, "Zero size logfn %s, removing", logfn) |
615 | bb.utils.remove(logfn) | 616 | bb.utils.remove(logfn) |
616 | bb.utils.remove(loglink) | 617 | bb.utils.remove(loglink) |
617 | event.fire(TaskSucceeded(task, logfn, localdata), localdata) | 618 | event.fire(TaskSucceeded(task, fn, logfn, localdata), localdata) |
618 | 619 | ||
619 | if not localdata.getVarFlag(task, 'nostamp', False) and not localdata.getVarFlag(task, 'selfstamp', False): | 620 | if not localdata.getVarFlag(task, 'nostamp', False) and not localdata.getVarFlag(task, 'selfstamp', False): |
620 | make_stamp(task, localdata) | 621 | make_stamp(task, localdata) |