listener: Try and protect actors against "bad" events
(cherry picked from commit aa010e03e9)
This commit is contained in:
parent
3d6270ad37
commit
3ff120a0e6
@ -31,7 +31,8 @@ class CoreListener(listener.Listener):
|
|||||||
:type event: string
|
:type event: string
|
||||||
:param kwargs: any other arguments to the specific event handlers
|
: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):
|
def track_playback_paused(self, tl_track, time_position):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -51,4 +51,8 @@ class Listener(object):
|
|||||||
:type event: string
|
:type event: string
|
||||||
:param kwargs: any other arguments to the specific event handlers
|
: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)
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class MpdDispatcher(object):
|
|||||||
return self._call_next_filter(request, response, filter_chain)
|
return self._call_next_filter(request, response, filter_chain)
|
||||||
|
|
||||||
def handle_idle(self, subsystem):
|
def handle_idle(self, subsystem):
|
||||||
|
# TODO: validate against mopidy/mpd/protocol/status.SUBSYSTEMS
|
||||||
self.context.events.add(subsystem)
|
self.context.events.add(subsystem)
|
||||||
|
|
||||||
subsystems = self.context.subscriptions.intersection(
|
subsystems = self.context.subscriptions.intersection(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user