All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bb.build: in _exec_task, catch errors from TaskStarted
@ 2016-09-16 20:00 Christopher Larson
  2016-09-16 20:01 ` Christopher Larson
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Larson @ 2016-09-16 20:00 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] 4+ messages in thread

* Re: [PATCH] bb.build: in _exec_task, catch errors from TaskStarted
  2016-09-16 20:00 [PATCH] bb.build: in _exec_task, catch errors from TaskStarted Christopher Larson
@ 2016-09-16 20:01 ` Christopher Larson
  2016-09-16 20:04   ` Christopher Larson
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Larson @ 2016-09-16 20:01 UTC (permalink / raw)
  To: bitbake-devel@lists.openembedded.org; +Cc: Christopher Larson

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

On Fri, Sep 16, 2016 at 1:00 PM, Christopher Larson <kergoth@gmail.com>
wrote:

> 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>
>

This supercedes 'bb.build: in _exec_task, catch BBHandledException’.
-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 1508 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bb.build: in _exec_task, catch errors from TaskStarted
  2016-09-16 20:01 ` Christopher Larson
@ 2016-09-16 20:04   ` Christopher Larson
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2016-09-16 20:04 UTC (permalink / raw)
  To: bitbake-devel@lists.openembedded.org; +Cc: Christopher Larson

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]

On Fri, Sep 16, 2016 at 1:01 PM, Christopher Larson <chris_larson@mentor.com
> wrote:

> On Fri, Sep 16, 2016 at 1:00 PM, Christopher Larson <kergoth@gmail.com>
> wrote:
>
>> 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>
>>
>
> This supercedes 'bb.build: in _exec_task, catch BBHandledException’.
>

Sigh, copy/paste error. This supercedes 'bb.build: in _exec_task, move
TaskStarted into try/except’. We want this and the BBHandledException patch
both applied. I’ll just send a v2 to avoid confusion :)
-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 2120 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] bb.build: in _exec_task, catch errors from TaskStarted
@ 2016-10-04 16:11 Christopher Larson
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2016-10-04 16:11 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

We don't always want a traceback when an exception is raised by the
TaskStarted event handler. Silently return if we get a SystemExit or
HandledException, and print the error and return for FuncFailed.

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>
---
 bitbake/lib/bb/build.py | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 2ed0441..666fe08 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -560,24 +560,32 @@ 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
+        try:
+            event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
+        except (bb.BBHandledException, SystemExit):
+            return 1
+        except FuncFailed as exc:
             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
+            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] 4+ messages in thread

end of thread, other threads:[~2016-10-04 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-16 20:00 [PATCH] bb.build: in _exec_task, catch errors from TaskStarted Christopher Larson
2016-09-16 20:01 ` Christopher Larson
2016-09-16 20:04   ` Christopher Larson
  -- strict thread matches above, loose matches on Subject: below --
2016-10-04 16:11 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.