forked from platypush/platypush
Always handle at least one retry on mpd plugin _exec method, the TCP connection to a mopidy server can really be shaky
This commit is contained in:
parent
7c817ba0c6
commit
32cdab5530
1 changed files with 7 additions and 2 deletions
|
@ -43,7 +43,7 @@ class MusicMpdPlugin(MusicPlugin):
|
||||||
self.client.connect(self.host, self.port)
|
self.client.connect(self.host, self.port)
|
||||||
return self.client
|
return self.client
|
||||||
|
|
||||||
def _exec(self, method, *args, **kwargs):
|
def _exec(self, method, n_tries=2, *args, **kwargs):
|
||||||
return_status = kwargs.pop('return_status') \
|
return_status = kwargs.pop('return_status') \
|
||||||
if 'return_status' in kwargs else True
|
if 'return_status' in kwargs else True
|
||||||
|
|
||||||
|
@ -60,6 +60,11 @@ class MusicMpdPlugin(MusicPlugin):
|
||||||
self.logger.warning('Exception while executing MPD method {}: {}'.
|
self.logger.warning('Exception while executing MPD method {}: {}'.
|
||||||
format(method, str(e)))
|
format(method, str(e)))
|
||||||
self.client = None
|
self.client = None
|
||||||
|
|
||||||
|
if n_tries > 0:
|
||||||
|
return self._exec(method, n_tries=n_tries-1,
|
||||||
|
return_status=return_status, *args, **kwargs)
|
||||||
|
else:
|
||||||
return (None, str(e))
|
return (None, str(e))
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
Loading…
Reference in a new issue