]> kaliko git repositories - mpd-sima.git/blobdiff - sima/core.py
Fixed SIGHUP issue hopefully.
[mpd-sima.git] / sima / core.py
index 634db4b1cc06c83e651e99f88a9c0c23fd949afa..7a17c5f8844923c3c590648afe4c344954ce5bcd 100644 (file)
@@ -46,6 +46,7 @@ class Sima(Daemon):
         self.plugins = list()
         self.player = self.__get_player()  # Player client
         try:
+            self.log.info('Connecting MPD: {0}:{1}'.format(*self.player._mpd))
             self.player.connect()
         except (PlayerError, PlayerUnHandledError) as err:
             self.log.warning('Player: {}'.format(err))
@@ -63,7 +64,7 @@ class Sima(Daemon):
         self.short_history.appendleft(self.player.current)
 
     def register_plugin(self, plugin_class):
-        """Registers plubin in Sima instance..."""
+        """Registers plugin in Sima instance..."""
         self.plugins.append(plugin_class(self))
 
     def foreach_plugin(self, method, *args, **kwds):
@@ -122,16 +123,20 @@ 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.')
-        self.player.disconnect()
+        # Cleaning pending command
+        self.player.clean()
         self.foreach_plugin('shutdown')
+        self.player.disconnect()
 
         self.log.info('The way is shut, it was made by those who are dead. '
                       'And the dead keep it…')