From 15a233a9273d0ba57be23a8afe6456ddebfca50a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 17 Apr 2018 09:27:37 +0200 Subject: [PATCH] Keep reloading the MPD plugin in the MPD backend if the plugin crashed or keeps being null --- platypush/backend/music/mpd/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platypush/backend/music/mpd/__init__.py b/platypush/backend/music/mpd/__init__.py index 6797ba97..1bda316a 100644 --- a/platypush/backend/music/mpd/__init__.py +++ b/platypush/backend/music/mpd/__init__.py @@ -27,9 +27,16 @@ class MusicMpdBackend(Backend): last_state = None last_track = None last_playlist = None + plugin = None while not self.should_stop(): - plugin = get_plugin('music.mpd') + while not plugin: + plugin = get_plugin('music.mpd') + if not plugin: + logging.info('Reloading crashed MPD plugin') + plugin = get_plugin('music.mpd', reload=True) + time.sleep(self.poll_seconds) + status = plugin.status().output track = plugin.currentsong().output state = status['state'].lower()