PsychoPy experiment freezes but no error (when I add odd/even distractor task code to my experiment)

OS (e.g. Win10): MacOS 14.4.1
PsychoPy version (e.g. 1.84.x): 2024.1.4


I have created a word-cue memory experiment where words appear for up to 16 seconds. If participants respond before the 16 seconds are up, the word disappears and they have to complete an odd/even distractor task (i.e., press 1 if the number is odd and 0 if the number is even) for the remainder of the 16 seconds. Therefore, the duration of this distractor task will differ on each trial, depending on when participants respond to the word.

I implemented this by adding a code component to the word-cue routine where a random integer between 1-9 is generated, and changes each time the participant responds for the remainder of the trial. This seems to run fine, however if I run the experiment with all 100 word cues, the experiment freezes near the end and the data does not save, with no error message.

I have attached the word-cue memory experiment with all other components removed, and the excel file containing the word cues.

WordCue_OddEven.psyexp (90.7 KB)

wordcues.xlsx (9.9 KB)

I would appreciate if I could receive any feedback on why the code might be causing the application to freeze and whether there is an alternative solution to add the odd/even distractor task to my experiment.

Thank you,