From 4ff6351869dc6996d310d893e7280c347900a5aa Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Fri, 29 Sep 2023 09:35:21 -0700 Subject: [PATCH] Refactor skills status check to resolve init bug #30 --- ovos_gui/namespace.py | 8 +------- ovos_gui/service.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ovos_gui/namespace.py b/ovos_gui/namespace.py index 9903e55..3cde48f 100644 --- a/ovos_gui/namespace.py +++ b/ovos_gui/namespace.py @@ -464,12 +464,6 @@ def __init__(self, core_bus: MessageBusClient): self._init_gui_file_share() self._define_message_handlers() - resp = self.core_bus.wait_for_response(Message("mycroft.skills.is_ready", - context={"source": "gui", "destination": ["skills"]})) - if resp and resp.data.get("status"): - LOG.debug("Skills service already running") - self.handle_ready() - @property def _active_homescreen(self) -> str: return Configuration().get('gui', {}).get('idle_display_skill') @@ -512,7 +506,7 @@ def _define_message_handlers(self): self.core_bus.on("gui.page_gained_focus", self.handle_page_gained_focus) self.core_bus.on("mycroft.skills.trained", self.handle_ready) - def handle_ready(self, message=None): + def handle_ready(self, message): self._ready_event.set() self.core_bus.on("gui.volunteer_page_upload", self.handle_gui_pages_available) diff --git a/ovos_gui/service.py b/ovos_gui/service.py index 8481e1a..c30e1e3 100644 --- a/ovos_gui/service.py +++ b/ovos_gui/service.py @@ -1,4 +1,4 @@ -from ovos_bus_client import MessageBusClient +from ovos_bus_client import MessageBusClient, Message from ovos_utils.log import LOG from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState from ovos_config.config import Configuration @@ -60,6 +60,15 @@ def run(self): # if they may cause the Service to fail. self.status.set_alive() self._init_bus_client() + + # Bus is connected, check if the skills service is ready + resp = self.bus.wait_for_response( + Message("mycroft.skills.is_ready", + context={"source": "gui", "destination": ["skills"]})) + if resp and resp.data.get("status"): + LOG.debug("Skills service already running") + self.gui.handle_ready(resp) + self.extension_manager = ExtensionsManager("EXTENSION_SERVICE", self.bus, self.gui) self.status.set_ready()