Skip to content

Commit

Permalink
Event plugin prints event trace on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Gjum committed Jan 31, 2016
1 parent da63be9 commit c41c27f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spockbot/plugins/core/event.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit c41c27f

Please # to comment.