listener: Try and protect actors against "bad" events

This commit is contained in:
Thomas Adamcik 2015-12-04 23:38:55 +01:00
parent a086857dd7
commit aa010e03e9
3 changed files with 8 additions and 2 deletions

View File

@ -31,7 +31,8 @@ class CoreListener(listener.Listener):
:type event: string
:param kwargs: any other arguments to the specific event handlers
"""
getattr(self, event)(**kwargs)
# Just delegate to parent, entry mostly for docs.
super(CoreListener, self).on_event(event, **kwargs)
def track_playback_paused(self, tl_track, time_position):
"""

View File

@ -41,4 +41,8 @@ class Listener(object):
:type event: string
:param kwargs: any other arguments to the specific event handlers
"""
getattr(self, event)(**kwargs)
try:
getattr(self, event)(**kwargs)
except Exception:
# Ensure we don't crash the actor due to "bad" events.
logger.exception('Triggering event failed: %s', event)

View File

@ -47,6 +47,7 @@ class MpdDispatcher(object):
return self._call_next_filter(request, response, filter_chain)
def handle_idle(self, subsystem):
# TODO: validate against mopidy/mpd/protocol/status.SUBSYSTEMS
self.context.events.add(subsystem)
subsystems = self.context.subscriptions.intersection(