Wait for a skill to finish processing

Hello,

I have a block of code similar to the one listed below, and it is supposed to trigger skills one after the other. However, without something like time.sleep(x), the skills are triggered at the same time, and I was wondering if there is a better way of getting the system to wait, ie., without having to hardcode in a specific duration of time.

for i, message in enumerate(messages):
            self.speak(f"Processing request {i + 1}", wait=True)
            self.bus.emit(
                Message("recognizer_loop:utterance", {"utterances": [message]})
            )
            time.sleep(10)

Thank you for your time!

There is a message emitted by Mycroft to the message bus when a skill has been handled. You can subscribe to the event, and take action whenever that message is emitted.

See mycroft_routine_skill/__init__.py at master · ChristopherRogers1991/mycroft_routine_skill · GitHub

You’ll need to track what you’ve triggered (to ensure the message corresponds to what your skill triggered, and not user interaction or another skill), and you may want some timeout, so you don’t wait indefinitely. See mycroft_routine_skill/__init__.py at master · ChristopherRogers1991/mycroft_routine_skill · GitHub

1 Like

I will look into implementing that, thank you!