]> kaliko git repositories - mpd-sima.git/commitdiff
Fixed SIGHUP issue hopefully.
authorkaliko <kaliko@azylum.org>
Tue, 17 Jun 2014 14:59:52 +0000 (16:59 +0200)
committerkaliko <kaliko@azylum.org>
Tue, 17 Jun 2014 14:59:52 +0000 (16:59 +0200)
Need python-musicpd >= 0.4.1

setup.py
sima/client.py
sima/core.py
sima/lib/player.py

index 46f06a2f7fb31248cc1dcf52bb8134c2873f1b18..036f85e22d643b5064712cff1c3bcca5f4b5b9f6 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -39,7 +39,7 @@ setup(name='MPD_sima',
       keywords='MPD',
       long_description=DESCRIPTION,
       classifiers=classifiers,
-      install_requires=['python-musicpd', 'requests'],
+      install_requires=['python-musicpd>=0.4.1', 'requests>= 2.0.2'],
       packages=find_packages(exclude=["tests"]),
       include_package_data=True,
       data_files=data_files,
index c04b259a90a147e4d3545012f8232fcd8ff39270..8481f5cfa71d3e7fe35b9fecece2238ae24c7c0d 100644 (file)
@@ -288,9 +288,9 @@ class PlayerClient(Player):
     def monitor(self):
         curr = self.current
         try:
-            self._client.send_idle('database', 'playlist', 'player', 'options')
+            self.send_idle('database', 'playlist', 'player', 'options')
             select([self._client], [], [], 60)
-            ret = self._client.fetch_idle()
+            ret = self.fetch_idle()
             if self.__skipped_track(curr):
                 ret.append('skipped')
             if 'database' in ret:
@@ -299,6 +299,14 @@ class PlayerClient(Player):
         except (MPDError, IOError) as err:
             raise PlayerError("Couldn't init idle: %s" % err)
 
+    def clean(self):
+        """Clean blocking event (idle) and pending commands
+        """
+        if 'idle' in self._client._pending:
+            self._client.noidle()
+        elif self._client._pending:
+            self.log.warning('pending commands: {}'.format(self._client._pending))
+
     def remove(self, position=0):
         self._client.delete(position)
 
index cf011c7e11edad3606e4a0679d6ce362829e8d77..7a17c5f8844923c3c590648afe4c344954ce5bcd 100644 (file)
@@ -123,14 +123,18 @@ class Sima(Daemon):
 
     def hup_handler(self, signum, frame):
         self.log.warning('Caught a sighup!')
-        self.player.disconnect()
+        # Cleaning pending command
+        self.player.clean()
         self.foreach_plugin('shutdown')
+        self.player.disconnect()
         raise SigHup('SIGHUP caught!')
 
     def shutdown(self):
         """General shutdown method
         """
         self.log.warning('Starting shutdown.')
+        # Cleaning pending command
+        self.player.clean()
         self.foreach_plugin('shutdown')
         self.player.disconnect()
 
index 6b6d2cba4dec19ff4cd19039f9a1ac4c3c8ced9e..37b3c7202dc392b842e25ff783effd34a7c6081f 100644 (file)
@@ -57,6 +57,10 @@ class Player(object):
         """
         raise NotImplementedError
 
+    def clean(self):
+        """Any cleanup necessary"""
+        pass
+
     def remove(self, position=0):
         """Removes the oldest element of the playlist (index 0)
         """