* [PATCHv2 1/2] bb.build: in _exec_task, catch BBHandledException
@ 2016-09-16 20:05 Christopher Larson
2016-09-16 20:05 ` [PATCHv2 2/2] bb.build: in _exec_task, catch errors from TaskStarted Christopher Larson
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2016-09-16 20:05 UTC (permalink / raw)
To: bitbake-devel; +Cc: Christopher Larson
From: Christopher Larson <chris_larson@mentor.com>
We don't want a traceback for this exception, we need to catch it, fire
TaskFailed, and return failure.
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
lib/bb/build.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index fcf0149..2ed0441 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -575,6 +575,9 @@ def _exec_task(fn, task, d, quieterr):
logger.error(str(exc))
event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata)
return 1
+ except bb.BBHandledException:
+ event.fire(TaskFailed(task, logfn, localdata, True), localdata)
+ return 1
finally:
sys.stdout.flush()
sys.stderr.flush()
--
2.8.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCHv2 2/2] bb.build: in _exec_task, catch errors from TaskStarted
2016-09-16 20:05 [PATCHv2 1/2] bb.build: in _exec_task, catch BBHandledException Christopher Larson
@ 2016-09-16 20:05 ` Christopher Larson
2016-09-17 5:12 ` Christopher Larson
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2016-09-16 20:05 UTC (permalink / raw)
To: bitbake-devel; +Cc: Christopher Larson
From: Christopher Larson <chris_larson@mentor.com>
We want any exceptions raised by the TaskStarted event handlers to be caught
rather than unconditionally hitting the exception formatting + traceback in
exec_task, otherwise we can't cleanly exit the task with a nice message from
such a handler.
This is done via a separate try/catch block, to avoid firing TaskFailed if all
the TaskStarted event handlers didn't complete, otherwise the bitbake UIs get
unhappy.
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
lib/bb/build.py | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 2ed0441..b74557a 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -560,24 +560,29 @@ def _exec_task(fn, task, d, quieterr):
flags = localdata.getVarFlags(task)
- event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
try:
- for func in (prefuncs or '').split():
- exec_func(func, localdata)
- exec_func(task, localdata)
- for func in (postfuncs or '').split():
- exec_func(func, localdata)
- except FuncFailed as exc:
- if quieterr:
- event.fire(TaskFailedSilent(task, logfn, localdata), localdata)
- else:
- errprinted = errchk.triggered
- logger.error(str(exc))
- event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata)
- return 1
- except bb.BBHandledException:
- event.fire(TaskFailed(task, logfn, localdata, True), localdata)
- return 1
+ try:
+ event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
+ except BaseException:
+ return 1
+
+ try:
+ for func in (prefuncs or '').split():
+ exec_func(func, localdata)
+ exec_func(task, localdata)
+ for func in (postfuncs or '').split():
+ exec_func(func, localdata)
+ except FuncFailed as exc:
+ if quieterr:
+ event.fire(TaskFailedSilent(task, logfn, localdata), localdata)
+ else:
+ errprinted = errchk.triggered
+ logger.error(str(exc))
+ event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata)
+ return 1
+ except bb.BBHandledException:
+ event.fire(TaskFailed(task, logfn, localdata, True), localdata)
+ return 1
finally:
sys.stdout.flush()
sys.stderr.flush()
--
2.8.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCHv2 2/2] bb.build: in _exec_task, catch errors from TaskStarted
2016-09-16 20:05 ` [PATCHv2 2/2] bb.build: in _exec_task, catch errors from TaskStarted Christopher Larson
@ 2016-09-17 5:12 ` Christopher Larson
0 siblings, 0 replies; 3+ messages in thread
From: Christopher Larson @ 2016-09-17 5:12 UTC (permalink / raw)
To: bitbake-devel; +Cc: Christopher Larson
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
On Fri, Sep 16, 2016 at 1:05 PM, Christopher Larson <kergoth@gmail.com>
wrote:
> + try:
> + event.fire(TaskStarted(task, logfn, flags, localdata),
> localdata)
> + except BaseException:
> + return 1
>
Thinking about it, this isn’t ideal either, as it will obscure cases where
a traceback is most appropriate. Will need to duplicate the handling of
BBHandledException and possibly SystemExit, I expect, instead.
--
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
[-- Attachment #2: Type: text/html, Size: 1084 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-17 5:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16 20:05 [PATCHv2 1/2] bb.build: in _exec_task, catch BBHandledException Christopher Larson
2016-09-16 20:05 ` [PATCHv2 2/2] bb.build: in _exec_task, catch errors from TaskStarted Christopher Larson
2016-09-17 5:12 ` Christopher Larson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.