From 89ea4798bf19feec5e92fdb347aa289c9d1df2e2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 9 Jan 2019 22:20:01 +0100 Subject: [PATCH] Restored retry logic in mpd backend --- platypush/backend/music/mpd/__init__.py | 36 ++++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/platypush/backend/music/mpd/__init__.py b/platypush/backend/music/mpd/__init__.py index 1c21da718..3275877ce 100644 --- a/platypush/backend/music/mpd/__init__.py +++ b/platypush/backend/music/mpd/__init__.py @@ -50,24 +50,28 @@ class MusicMpdBackend(Backend): plugin = None while not self.should_stop(): - try: - plugin = get_plugin('music.mpd') - if not plugin: - raise StopIteration + success = False - status = plugin.status().output - if not status or status.get('state') is None: - raise StopIteration + while not success: + try: + plugin = get_plugin('music.mpd') + if not plugin: + raise StopIteration - track = plugin.currentsong().output - state = status['state'].lower() - playlist = status['playlist'] - except StopIteration: - pass - except Exception as e: - self.logger.debug(e) - finally: - time.sleep(self.poll_seconds) + status = plugin.status().output + if not status or status.get('state') is None: + raise StopIteration + + track = plugin.currentsong().output + state = status['state'].lower() + playlist = status['playlist'] + success = True + except StopIteration: + pass + except Exception as e: + self.logger.debug(e) + finally: + time.sleep(self.poll_seconds) if state != last_state: if state == 'stop':