]> kaliko git repositories - mpd-sima.git/commitdiff
Fixed unhandled exception in monitor (idle MPD command)
authorkaliko <kaliko@azylum.org>
Fri, 29 Oct 2021 11:55:15 +0000 (13:55 +0200)
committerkaliko <kaliko@azylum.org>
Fri, 29 Oct 2021 11:55:15 +0000 (13:55 +0200)
Socket timeout was handled but musicpd exception raised on server lost
was not. For instance ConnectionError: "Connection lost while reading
line" was not catch.

sima/info.py
sima/mpdclient.py

index 86ec802b95f4941829522f73fd723fd6cc1aabc4..799244b0cda2ef595ebdda44c81d5253aca363ed 100644 (file)
@@ -12,7 +12,7 @@ short.
 """
 
 
-__version__ = '0.18.0.dev1'
+__version__ = '0.18.0.dev2'
 __author__ = 'kaliko'
 __email__ = 'kaliko@azylum.org'
 __url__ = 'git://git.kaliko.me/sima.git'
index 3bd13aef7b4b3705c092f086c034723d1b364680..c4ebadeaa7e1d4453aa92d8bbda5830c0715842e 100644 (file)
@@ -238,21 +238,23 @@ class MPD(MPDClient):
         """
         curr = self.current
         select_timeout = 5
-        while True:
-            self.send_idle('database', 'playlist', 'player', 'options')
-            _read, _, _ = select([self], [], [], select_timeout)
-            if _read:  # tries to read response
-                ret = self.fetch_idle()
-                if self._skipped_track(curr):
-                    ret.append('skipped')
-                if 'database' in ret:
-                    self._reset_cache()
-                return ret
-            #  Nothing to read, canceling idle
-            try:  # noidle cmd does not go through __getattr__, need to catch OSError then
+        try:  # noidle cmd does not go through __getattr__, need to catch OSError then
+            while True:
+                self.send_idle('database', 'playlist', 'player', 'options')
+                _read, _, _ = select([self], [], [], select_timeout)
+                if _read:  # tries to read response
+                    ret = self.fetch_idle()
+                    if self._skipped_track(curr):
+                        ret.append('skipped')
+                    if 'database' in ret:
+                        self._reset_cache()
+                    return ret
+                #  Nothing to read, canceling idle
                 self.noidle()
-            except OSError as err:
-                raise PlayerError(err) from err
+        except OSError as err:
+            raise PlayerError(err) from err
+        except MPDError as err:  # hight level MPD client errors
+            raise PlayerError(err) from err
 
     def clean(self):
         """Clean blocking event (idle) and pending commands