All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] event: Handle recursive events and the data store better
@ 2015-06-25 21:52 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2015-06-25 21:52 UTC (permalink / raw)
  To: bitbake-devel

Events can call each other recursively, e.g. an event handler can call
bb.note which in turn generates another event. If these loop, it
can lead to multiple deletions of 'd' from __builtins__ which
can fail since __builtins__ is global scope.

Add handling to only remove 'd' when we added it and it wasn't already
present.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 80e3796..6951e21 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -72,7 +72,10 @@ _eventfilter = None
 
 def execute_handler(name, handler, event, d):
     event.data = d
-    __builtins__['d'] = d
+    addedd = False
+    if 'd' not in __builtins__:
+        __builtins__['d'] = d
+        addedd = True
     try:
         ret = handler(event)
     except bb.parse.SkipRecipe:
@@ -88,7 +91,8 @@ def execute_handler(name, handler, event, d):
             logger.error("Execution of event handler '%s' failed (exit code %s)" % (name, exc.code))
     finally:
         del event.data
-        del __builtins__['d']
+        if addedd:
+            del __builtins__['d']
 
 def fire_class_handlers(event, d):
     if isinstance(event, logging.LogRecord):




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-25 21:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-25 21:52 [PATCH] event: Handle recursive events and the data store better Richard Purdie

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.