Register bus handlers requiring loop after loop exists #2926
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
AttributeError was being thrown by the Speech service.
Cause:
The main bus gets established and event handlers registered before the RecognizerLoop bus is established. Hence if something emits a
mycroft.mic.get_status
message in this short window, the handler will fail asloop is None
.Fix:
This change splits the bus events being registered into two groups:
open
and based on the existing #TODO this might get removed as a breaking change.How to test
I haven't created a way to reliably reproduce the issue and a unit test for this is proving difficult. Any suggestions welcome.
Would need to emit a message like
mycroft.mic.get_status
as the service is being established and verify that the handler is not called. Then once the service is established, re-emit the message and assert that the handler is called.Contributor license agreement signed?
@AIIX - the only thing calling this that I could see is mycroft-gui-mark-2. It's only going to not receive a response, and it's already doing that with the handler failing, but wanted to flag it in case this will impact that package in any way.