Repository: MycroftAI/mycroft-core

Issue:
precise child executables are left running
Running 18.2.4.  I am running a newer, compiled version of precise, but I assume this problem is in the code that execs it.

When I switch the wake word engine from precise to pocketsphinx using the configuration Skill, the precise children of mycroft/client/speech/main.py are still running.

If I keep switching precise/pocketsphinx, the number of precise children running grows each time I switch to precise.

```
$ ps -efH |grep mycroft
tlc     29478  5826  0 17:14 pts/5    00:00:00             /bin/bash ./start-mycroft.sh debug
tlc     29494 29478  0 17:14 pts/5    00:00:21               python /home/tlc/mycroft-core/mycroft/messagebus/service/main.py
tlc     29497 29478  1 17:14 pts/5    00:00:41               python /home/tlc/mycroft-core/mycroft/skills/main.py
tlc     29500 29478  0 17:14 pts/5    00:00:05               python /home/tlc/mycroft-core/mycroft/audio/main.py
tlc     29504 29478  2 17:14 pts/5    00:01:10               python /home/tlc/mycroft-core/mycroft/client/speech/main.py
tlc     29590 29504  0 17:14 pts/5    00:00:00                 /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc     29592 29590 18 17:14 pts/5    00:09:29                   /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc     31847 29504  0 17:38 pts/5    00:00:00                 /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc     31849 31847 19 17:38 pts/5    00:05:16                   /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc       428 29504  0 17:52 pts/5    00:00:00                 /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc       430   428  4 17:52 pts/5    00:00:36                   /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc       574 29504  0 17:54 pts/5    00:00:00                 /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc       576   574 40 17:54 pts/5    00:04:33                   /home/tlc/.mycroft/precise/precise-stream/precise-stream /home/tlc/.mycroft/precise/hey-mycroft.pb 1024
tlc     29506 29478  0 17:14 pts/5    00:00:06               python /home/tlc/mycroft-core/mycroft/client/text/main.py
```




Discussion:

Resolving patch:
diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py
--- a/mycroft/client/speech/hotword_factory.py
+++ b/mycroft/client/speech/hotword_factory.py
@@ -61,6 +61,14 @@ def found_wake_word(self, frame_data):
     def update(self, chunk):
         pass
 
+    def stop(self):
+        """ Perform any actions needed to shut down the hot word engine.
+
+            This may include things such as unload loaded data or shutdown
+            external processess.
+        """
+        pass
+
 
 class PocketsphinxHotWord(HotWordEngine):
     def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
@@ -222,6 +230,10 @@ def found_wake_word(self, frame_data):
             return True
         return False
 
+    def stop(self):
+        if self.runner:
+            self.runner.stop()
+
 
 class SnowboyHotWord(HotWordEngine):
     def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
diff --git a/mycroft/client/speech/listener.py b/mycroft/client/speech/listener.py
--- a/mycroft/client/speech/listener.py
+++ b/mycroft/client/speech/listener.py
@@ -344,6 +344,7 @@ def reload(self):
             Reload configuration and restart consumer and producer
         """
         self.stop()
+        self.wakeword_recognizer.stop()
         # load config
         self._load_config()
         # restart


Test patch: