Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2945 from MycroftAI/refactor/race-condition-comment
Browse files Browse the repository at this point in the history
Added comments to document race condition
  • Loading branch information
chrisveilleux committed Jul 7, 2021
2 parents 2deab67 + 18cb280 commit 10d1dcf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mycroft/skills/mycroft_skill/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,16 @@ def converse(self, message=None):
return False

def __get_response(self):
"""Helper to get a reponse from the user
"""Helper to get a response from the user
NOTE: There is a race condition here. There is a small amount of
time between the end of the device speaking and the converse method
being overridden in this method. If an utterance is injected during
this time, the wrong converse method is executed. The condition is
hidden during normal use due to the amount of time it takes a user
to speak a response. The condition is revealed when an automated
process injects an utterance quicker than this method can flip the
converse methods.
Returns:
str: user's response or None on a timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ def check_contains(message):
@then('the user replies "{text}"')
@then('the user says "{text}"')
def then_user_follow_up(context, text):
"""Send a user response after being prompted by device.
The sleep after the device is finished speaking is to address a race
condition in the MycroftSkill base class conversational code. It can
be removed when the race condition is addressed.
"""
wait_while_speaking()
time.sleep(2)
context.bus.emit(Message('recognizer_loop:utterance',
Expand Down

0 comments on commit 10d1dcf

Please sign in to comment.