Skip to content

Commit

Permalink
Refactor skills status check to resolve init bug (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel McKnight <daniel@neon.ai>
  • Loading branch information
NeonDaniel and NeonDaniel authored Sep 29, 2023
1 parent 462cbd6 commit 62e0332
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 1 addition & 7 deletions ovos_gui/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion ovos_gui/service.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 62e0332

Please sign in to comment.