Restored retry logic in mpd backend

This commit is contained in:
Fabio Manganiello 2019-01-09 22:20:01 +01:00
parent 156e2e8b5a
commit 89ea4798bf
1 changed files with 20 additions and 16 deletions

View File

@ -50,24 +50,28 @@ class MusicMpdBackend(Backend):
plugin = None plugin = None
while not self.should_stop(): while not self.should_stop():
try: success = False
plugin = get_plugin('music.mpd')
if not plugin:
raise StopIteration
status = plugin.status().output while not success:
if not status or status.get('state') is None: try:
raise StopIteration plugin = get_plugin('music.mpd')
if not plugin:
raise StopIteration
track = plugin.currentsong().output status = plugin.status().output
state = status['state'].lower() if not status or status.get('state') is None:
playlist = status['playlist'] raise StopIteration
except StopIteration:
pass track = plugin.currentsong().output
except Exception as e: state = status['state'].lower()
self.logger.debug(e) playlist = status['playlist']
finally: success = True
time.sleep(self.poll_seconds) except StopIteration:
pass
except Exception as e:
self.logger.debug(e)
finally:
time.sleep(self.poll_seconds)
if state != last_state: if state != last_state:
if state == 'stop': if state == 'stop':