From fc3f53f32bd75097f964a59b3c61748b5da4ef12 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 7 Nov 2018 18:04:37 +0100 Subject: [PATCH] Retry logic for getting mpd status --- platypush/plugins/music/mpd/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index 44b791b396..4180d05943 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -1,5 +1,6 @@ import mpd import re +import time from platypush.plugins import action from platypush.plugins.music import MusicPlugin @@ -292,7 +293,16 @@ class MusicMpdPlugin(MusicPlugin): } """ - return self.client.status() + retries = 0 + max_retries = 2 + + while retries < max_retries: + try: + return self.client.status() + except Exception as e: + self.logger.warning('Unable to parse mpd status: {}'.format(e)) + retries += 1 + time.sleep(1) @action def currentsong(self):