Retry logic for getting mpd status

This commit is contained in:
Fabio Manganiello 2018-11-07 18:04:37 +01:00
parent 26ec213098
commit fc3f53f32b

View file

@ -1,5 +1,6 @@
import mpd import mpd
import re import re
import time
from platypush.plugins import action from platypush.plugins import action
from platypush.plugins.music import MusicPlugin from platypush.plugins.music import MusicPlugin
@ -292,7 +293,16 @@ class MusicMpdPlugin(MusicPlugin):
} }
""" """
retries = 0
max_retries = 2
while retries < max_retries:
try:
return self.client.status() return self.client.status()
except Exception as e:
self.logger.warning('Unable to parse mpd status: {}'.format(e))
retries += 1
time.sleep(1)
@action @action
def currentsong(self): def currentsong(self):