Add timeout to consumer queue get
Prevents hanging on config reload
# limitations under the License.
#
import time
-from Queue import Queue
+from Queue import Queue, Empty
from threading import Thread
import speech_recognition as sr
@@ -96,9 +96,9 @@ class AudioConsumer(Thread):
self.read()
def read(self):
- audio = self.queue.get()
-
- if audio is None:
+ try:
+ audio = self.queue.get(0.5)
+ except Empty:
return
if self.state.sleeping:
