mpd connection errors are properly logged

This commit is contained in:
boyska 2016-09-28 12:22:35 +02:00
parent fd32e6b438
commit 84adc16cec
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9

View file

@ -41,12 +41,11 @@ class MpcWatcher(ParentedLet):
status = self.client.idle()[0] status = self.client.idle()[0]
except (ConnectionError, ConnectionRefusedError, except (ConnectionError, ConnectionRefusedError,
FileNotFoundError) as exc: FileNotFoundError) as exc:
# TODO: should we emit an error just in case? self.log.warning('Connection to MPD failed ({}: {})'.
self.log.debug('connection with MPD failed ({}: {})'. format(exc.__class__.__name__, exc))
format(exc.__class__.__name__, exc))
self.client = None self.client = None
first_after_connection = True first_after_connection = True
gevent.sleep(1) gevent.sleep(5)
continue continue
else: else:
first_after_connection = False first_after_connection = False
@ -64,7 +63,13 @@ class Player:
def _get_mpd(self): def _get_mpd(self):
mpd_client = MPDClient(use_unicode=True) mpd_client = MPDClient(use_unicode=True)
mpd_client.connect(self.conf['MPD_HOST'], self.conf['MPD_PORT']) try:
mpd_client.connect(self.conf['MPD_HOST'], self.conf['MPD_PORT'])
except (ConnectionError, ConnectionRefusedError,
FileNotFoundError) as exc:
self.log.warning('Connection to MPD failed ({}: {})'.
format(exc.__class__.__name__, exc))
raise gevent.GreenletExit()
return mpd_client return mpd_client
@property @property