Coroutines ending on keypress
Hi everyone! I have a problem that should be simple but I don't know how to solve it.
I need to have the following situation in my experiment:
I have a stimulus show for 60 seconds or until keypress. After 50 seconds of stimulus presentation, I have a beep that should go of. If a key is pressed before the 50 seconds, the beep should not go of. My idea of doing this is having the stimulus show with a duration of 0s, followed by coroutines containing the beep (which is a 60s file with the beep at 50s) and keyboard response. Now, the problem is that I can't seem to program the coroutines to last until a key is pressed. I have tried adding the following inline script to the coroutines:
"""A generator that breaks a coroutine when a response is given."""
# To start, set response to None
new_keyboard_response1.response = None
# Loop while coroutines is running
# If a response is given, set the coroutines duration to 0, causing
# it to stop
if new_keyboard_response1.response is not None:
items['new_coroutines'].var.duration = 0
# Also break if the coroutines signals that it's over
keep_going = yield
if not keep_going:
However, when I do that and run the experiment, I get the following message:
"break_coroutines" is not defined
Also, the break_coroutines(): in my code is red.
Thank you in advance for your help.