aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-25 22:52:17 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-26 09:26:49 +0100
commitb45952650ce8f470f124df36185b79e0d3a1783a (patch)
tree9fad2fb44a9f2c3960f5314098934e2f1853be21
parente42d7c47a06fbb5981e0313478c8e3656b99f4e7 (diff)
downloadbitbake-b45952650ce8f470f124df36185b79e0d3a1783a.tar.gz
event: Handle recursive events and the data store better
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>
-rw-r--r--lib/bb/event.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/bb/event.py b/lib/bb/event.py
index f0391b856..61a7f4a26 100644
--- a/lib/bb/event.py
+++ b/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, bb.BBHandledException):
@@ -88,7 +91,8 @@ def execute_handler(name, handler, event, d):
raise
finally:
del event.data
- del __builtins__['d']
+ if addedd:
+ del __builtins__['d']
def fire_class_handlers(event, d):
if isinstance(event, logging.LogRecord):