From c41c27fb901df2a64dc13251000526edede2d3dc Mon Sep 17 00:00:00 2001 From: Gjum Date: Sun, 31 Jan 2016 19:28:44 +0100 Subject: [PATCH] Event plugin prints event trace on exception --- spockbot/plugins/core/event.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spockbot/plugins/core/event.py b/spockbot/plugins/core/event.py index a59838d..6cd644a 100644 --- a/spockbot/plugins/core/event.py +++ b/spockbot/plugins/core/event.py @@ -1,10 +1,10 @@ """ Provides the core event loop """ -import copy import logging import signal from collections import defaultdict +from copy import deepcopy from spockbot.plugins.base import pl_announce from spockbot.plugins.tools.event import EVENT_UNREGISTER @@ -56,10 +56,15 @@ def unreg_event_handler(self, event, handler): def emit(self, event, data=None): # the handler list of this event can change during handler execution, # so we loop over a copy - for handler in self.event_handlers[event][:]: - d = data.clone() if hasattr(data, 'clone') else copy.deepcopy(data) - if handler(event, d) == EVENT_UNREGISTER: - self.event_handlers[event].remove(handler) + try: + for handler in self.event_handlers[event][:]: + d = data.clone() if hasattr(data, 'clone') else deepcopy(data) + if handler(event, d) == EVENT_UNREGISTER: + self.event_handlers[event].remove(handler) + except: + logger.debug('EVENTCORE: Exception while emitting %s %s', + event, data) + raise def kill(self, *args): self.kill_event = True