Skip to contentSkip to conversation

bb.build: in _exec_task, move TaskStarted into try/except

PATCH In review Christopher Larson 2 participants 5 messages Sep 15, 2016 – Sep 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bb.build: in _exec_task, move TaskStarted into try/except

From: Christopher Larson <[email protected]>

We want any exceptions raised by the TaskStarted event handlers to be caught by the existing exception handling, 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.

---
 lib/bb/build.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/build.py +1 -1
index fcf0149..28401b3 100644
@@ -560,8 +560,8 @@ def _exec_task(fn, task, d, quieterr):
 
     flags = localdata.getVarFlags(task)
 
-    event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
     try:
+        event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
         for func in (prefuncs or '').split():
             exec_func(func, localdata)
         exec_func(task, localdata)
Signature · 1 line
2.8.0
#1 lore raw

PATCH 2/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
index 28401b3..8581e72 100644
@@ -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
#2 lore raw

Re: [PATCH 2/2] bb.build: in _exec_task, catch BBHandledException

Quoted 15 lines · Christopher Larson

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 +0 -0
index 28401b3..8581e72 100644

lib/bb/build.py def _exec_task(fn, task, d, quieterr): · line 582

Quoted 8 lines
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
 

Don’t merge this, v2 is forthcoming. Apparently firing the TaskFailed is problematic if it was the TaskStarted event handler which failed, as the UI won’t have the pid of the task, resulting in this:

Traceback (most recent call last):
File "/scratch/dogwood/pdk-licensing/poky/bitbake/lib/bb/ui/knotty.py",
line 426, in main
helper.eventHandler(event)
File "/scratch/dogwood/pdk-licensing/poky/bitbake/lib/bb/ui/uihelper.py",
line 48, in eventHandler
del self.running_tasks[event.pid]

Signature · 5 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#3 lore raw

Re: [PATCH 2/2] bb.build: in _exec_task, catch BBHandledException

On Fri, Sep 16, 2016 at 9:34 AM, Christopher Larson <[email protected]

Quoted 33 lines

wrote:

Quoted 15 lines · Christopher Larson

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 +0 -0
index 28401b3..8581e72 100644

lib/bb/build.py def _exec_task(fn, task, d, quieterr): · line 582

Quoted 8 lines
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
 

Don’t merge this, v2 is forthcoming. Apparently firing the TaskFailed is problematic if it was the TaskStarted event handler which failed, as the UI won’t have the pid of the task, resulting in this:

Quoted 8 lines

Traceback (most recent call last):
File "/scratch/dogwood/pdk-licensing/poky/bitbake/lib/bb/ui/knotty.py",
line 426, in main
helper.eventHandler(event)
File "/scratch/dogwood/pdk-licensing/poky/bitbake/lib/bb/ui/uihelper.py",
line 48, in eventHandler
del self.running_tasks[event.pid]

This is superceded by 'bb.build: in _exec_task, catch errors from TaskStarted’. Please review/apply that rather than this. Thanks.

Signature · 5 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#4 lore raw

Re: [PATCH 2/2] bb.build: in _exec_task, catch BBHandledException

On Fri, Sep 16, 2016 at 1:02 PM, Christopher Larson <[email protected]

Quoted 46 lines

wrote:

Quoted 31 lines · Christopher Larson
Quoted 15 lines · Christopher Larson

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 +0 -0
index 28401b3..8581e72 100644

lib/bb/build.py def _exec_task(fn, task, d, quieterr): · line 582

Quoted 8 lines
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
 

Don’t merge this, v2 is forthcoming. Apparently firing the TaskFailed is problematic if it was the TaskStarted event handler which failed, as the UI won’t have the pid of the task, resulting in this:

Quoted 8 lines

Traceback (most recent call last):
File "/scratch/dogwood/pdk-licensing/poky/bitbake/lib/bb/ui/knotty.py",
line 426, in main
helper.eventHandler(event)
File "/scratch/dogwood/pdk-licensing/poky/bitbake/lib/bb/ui/uihelper.py",
line 48, in eventHandler
del self.running_tasks[event.pid]

Quoted 2 lines

This is superceded by 'bb.build: in _exec_task, catch errors from TaskStarted’. Please review/apply that rather than this. Thanks.

Sigh, was on the wrong patch. We want this one, it’s not superceded. Ignore all this, a v2 series is forthcoming.

Signature · 5 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics