bb.build: in _exec_task, catch BBHandledException
PATCH v2 1/2 bb.build: in _exec_task, catch BBHandledException
From: Christopher Larson <[email protected]>
We don't want a traceback for this exception, we need to catch it, fire TaskFailed, and return failure.
--- lib/bb/build.py | 3 +++ 1 file changed, 3 insertions(+)
lib/bb/build.py +3 -0
@@ -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()
Signature · 1 line
2.8.0
PATCH v2 2/2 bb.build: in _exec_task, catch errors from TaskStarted
From: Christopher Larson <[email protected]>
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.
--- lib/bb/build.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
lib/bb/build.py +22 -17
@@ -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()
Signature · 1 line
2.8.0
Re: [PATCHv2 2/2] bb.build: in _exec_task, catch errors from TaskStarted
Review
Quoted 6 lines · Christopher Larson
(quoted diff) +2
-0+ try: + event.fire(TaskStarted(task, logfn, flags, localdata),localdata)
(quoted diff) +2
-0+ 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.
Signature · 5 lines
Christopher Larson kergoth at gmail dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics