Run queries in threads

pull/1956/head
Åke Forslund 2019-01-17 11:56:47 +01:00
parent f98e569259
commit d5f04ada76
1 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,7 @@ from enum import IntEnum
from abc import ABC, abstractmethod
from mycroft import MycroftSkill
from mycroft.messagebus.message import Message
from multiprocessing.pool import ThreadPool
class CQSMatchLevel(IntEnum):
@ -41,6 +42,8 @@ def handles_visuals(self, platform):
class CommonQuerySkill(MycroftSkill, ABC):
pool = ThreadPool(5)
def __init__(self, name=None, bus=None):
super().__init__(name, bus)
@ -51,6 +54,10 @@ class CommonQuerySkill(MycroftSkill, ABC):
self.add_event('question:action', self.__handle_query_action)
def __handle_question_query(self, message):
CommonQuerySkill.pool.apply_async(self.__thread_question_query,
args=[message])
def __thread_question_query(self, message):
search_phrase = message.data["phrase"]
# First, notify the requestor that we are attempting to handle