Experiment becomes unresponsive sometimes

An experiment I built in the Coder becomes unresponsive occasionally. The program works perfectly about 7/10 times I run it. But the other times, it becomes unresponsive on the final screen. The program should quit once a key is pressed, but sometimes it does not respond. This is a problem because the .csv data file does not save if the program does not quit properly. I’m looking for help figuring out why the unresponsiveness occurs some of time and what I could do to prevent that from happening.

I’m using psychopy v 1.90.2 on MacOS High Sierra v 10.13.6. The program was built in and runs from the coder view.

Here’s the code where the problem sometimes arises. The program remains on that final screen (with text displayed) regardless of which keys are pressed. When this happens, the only way to get rid of the final screen is to force quit, but the .csv data file does not save in those cases.

if end == 1:
    win.clearBuffer() #make screen black
    endText = visual.TextStim(win, text='Thanks!  You have finished the experiment.\n\nPlease notify the experimenter.', color='white', height=40, wrapWidth=winWidth)
    endText.draw()
    win.flip()
    event.waitKeys()
    core.quit()

Some suggestions/questions:

  • Is the experiment running in full screen mode? (If not, it is possible that some other window hidden behind it is receiving and swallowing the keyboard events (this might the most likely explanation given the variable nature of this issue and the code shown.)
  • Are you absolutely sure that this section of code is running (i.e. is there any other section that could be displaying that same text? This could particularly be an issue if the variable end could ever be a non-integer.)
  • put debugging print statements before and after the event.waitKeys() to see if that is the issue.
  • What happens if you replace event.waitKeys() with core.wait(10.0)?
  • Before this code section even starts, tell the TrialHandler to save your data.

PS it’s not great online etiquette to post the same question in different threads. It doesn’t lead to a quicker answer, just makes it more likely to cause duplication of effort and possibly annoyance leading to a response being less likely.

1 Like