Reload the MPD plugin in case of any errors during the status retrieval
This commit is contained in:
parent
15a233a927
commit
fcdc4d1af8
1 changed files with 12 additions and 8 deletions
|
@ -30,18 +30,22 @@ class MusicMpdBackend(Backend):
|
||||||
plugin = None
|
plugin = None
|
||||||
|
|
||||||
while not self.should_stop():
|
while not self.should_stop():
|
||||||
while not plugin:
|
success = False
|
||||||
plugin = get_plugin('music.mpd')
|
|
||||||
if not plugin:
|
while not success:
|
||||||
|
try:
|
||||||
|
plugin = get_plugin('music.mpd')
|
||||||
|
status = plugin.status().output
|
||||||
|
track = plugin.currentsong().output
|
||||||
|
state = status['state'].lower()
|
||||||
|
playlist = status['playlist']
|
||||||
|
success = True
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception(e)
|
||||||
logging.info('Reloading crashed MPD plugin')
|
logging.info('Reloading crashed MPD plugin')
|
||||||
plugin = get_plugin('music.mpd', reload=True)
|
plugin = get_plugin('music.mpd', reload=True)
|
||||||
time.sleep(self.poll_seconds)
|
time.sleep(self.poll_seconds)
|
||||||
|
|
||||||
status = plugin.status().output
|
|
||||||
track = plugin.currentsong().output
|
|
||||||
state = status['state'].lower()
|
|
||||||
playlist = status['playlist']
|
|
||||||
|
|
||||||
if state != last_state:
|
if state != last_state:
|
||||||
if state == 'stop':
|
if state == 'stop':
|
||||||
self.bus.post(MusicStopEvent(status=status, track=track))
|
self.bus.post(MusicStopEvent(status=status, track=track))
|
||||||
|
|
Loading…
Reference in a new issue