[bitbake-devel,09/13] bitbake: event: do not abort on UI handlers error

Submitted by Alexandru DAMIAN on Sept. 9, 2013, 4:41 p.m.

Details

Message ID 57e230f40897c8ce63ccd4056f56747d64235788.1378743829.git.alexandru.damian@intel.com
State New
Headers show

Commit Message

Alexandru DAMIAN Sept. 9, 2013, 4:41 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

Ignore runtime errors if UI handlers do something
funny, as exiting while the loop is running.

This allows the builder to continue even if something
happens to the UI handlers, useful for remote bitbake
server.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 bitbake/lib/bb/event.py | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 67cfcea..1258471 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -133,20 +133,24 @@  def fire_ui_handlers(event, d):
         return
 
     errors = []
-    for h in _ui_handlers:
-        #print "Sending event %s" % event
-        try:
-             if not _ui_logfilters[h].filter(event):
-                 continue
-             # We use pickle here since it better handles object instances
-             # which xmlrpc's marshaller does not. Events *must* be serializable
-             # by pickle.
-             if hasattr(_ui_handlers[h].event, "sendpickle"):
-                _ui_handlers[h].event.sendpickle((pickle.dumps(event)))
-             else:
-                _ui_handlers[h].event.send(event)
-        except:
-            errors.append(h)
+    try:
+        for h in _ui_handlers:
+            #print "Sending event %s" % event
+            try:
+                if not _ui_logfilters[h].filter(event):
+                    continue
+                # We use pickle here since it better handles object instances
+                # which xmlrpc's marshaller does not. Events *must* be serializable
+                # by pickle.
+                if hasattr(_ui_handlers[h].event, "sendpickle"):
+                    _ui_handlers[h].event.sendpickle((pickle.dumps(event)))
+                else:
+                    _ui_handlers[h].event.send(event)
+            except:
+                errors.append(h)
+    except RuntimeError:     # may happen that the ui handler simple disappears :D
+        errors.append(h)
+
     for h in errors:
         del _ui_handlers[h]
 

Comments

Richard Purdie Sept. 9, 2013, 4:49 p.m.
On Mon, 2013-09-09 at 17:41 +0100, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian@intel.com>
> 
> Ignore runtime errors if UI handlers do something
> funny, as exiting while the loop is running.

This does look rather strange to me. How can a handler exit within the
loop? The handler is either another process or something we're using an
xmlrpc call too. Fine, the other end can disappear but our local end
(and entry in _ui_handlers) should exist until we remove it ourselves?

Only the server itself can do the removal and the server is single
threaded?

Cheers,

Richard




> This allows the builder to continue even if something
> happens to the UI handlers, useful for remote bitbake
> server.
> 
> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
> ---
>  bitbake/lib/bb/event.py | 32 ++++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
> index 67cfcea..1258471 100644
> --- a/bitbake/lib/bb/event.py
> +++ b/bitbake/lib/bb/event.py
> @@ -133,20 +133,24 @@ def fire_ui_handlers(event, d):
>          return
>  
>      errors = []
> -    for h in _ui_handlers:
> -        #print "Sending event %s" % event
> -        try:
> -             if not _ui_logfilters[h].filter(event):
> -                 continue
> -             # We use pickle here since it better handles object instances
> -             # which xmlrpc's marshaller does not. Events *must* be serializable
> -             # by pickle.
> -             if hasattr(_ui_handlers[h].event, "sendpickle"):
> -                _ui_handlers[h].event.sendpickle((pickle.dumps(event)))
> -             else:
> -                _ui_handlers[h].event.send(event)
> -        except:
> -            errors.append(h)
> +    try:
> +        for h in _ui_handlers:
> +            #print "Sending event %s" % event
> +            try:
> +                if not _ui_logfilters[h].filter(event):
> +                    continue
> +                # We use pickle here since it better handles object instances
> +                # which xmlrpc's marshaller does not. Events *must* be serializable
> +                # by pickle.
> +                if hasattr(_ui_handlers[h].event, "sendpickle"):
> +                    _ui_handlers[h].event.sendpickle((pickle.dumps(event)))
> +                else:
> +                    _ui_handlers[h].event.send(event)
> +            except:
> +                errors.append(h)
> +    except RuntimeError:     # may happen that the ui handler simple disappears :D
> +        errors.append(h)
> +
>      for h in errors:
>          del _ui_handlers[h]
>