From 32cdab5530c16e7b28a43cadc005327239345599 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 13 Feb 2019 17:35:18 +0100 Subject: [PATCH] Always handle at least one retry on mpd plugin _exec method, the TCP connection to a mopidy server can really be shaky --- platypush/plugins/music/mpd/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index 42bcdbfc83..b35c128b63 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -43,7 +43,7 @@ class MusicMpdPlugin(MusicPlugin): self.client.connect(self.host, self.port) return self.client - def _exec(self, method, *args, **kwargs): + def _exec(self, method, n_tries=2, *args, **kwargs): return_status = kwargs.pop('return_status') \ if 'return_status' in kwargs else True @@ -60,7 +60,12 @@ class MusicMpdPlugin(MusicPlugin): self.logger.warning('Exception while executing MPD method {}: {}'. format(method, str(e))) self.client = None - return (None, str(e)) + + if n_tries > 0: + return self._exec(method, n_tries=n_tries-1, + return_status=return_status, *args, **kwargs) + else: + return (None, str(e)) @action def play(self, resource=None):