I developed an experiment script that is being used by both our lab and another lab. In the other lab’s setup, they have been experiencing seemingly random freezes on calls to
event.waitKeys(). The freezes occur on anywhere from 10-50% of the runs, and do not follow a consistent pattern. The freezes also never give an error code, which has made this problem difficult to diagnose.
When the program freezes, the CPU spikes to 100% usage, and the program will not respond until forced to quit. We determined that this is likely not a memory leak problem, as it can occur on the very first run of a session and does not increase in frequency throughout a session. We also used Activity Monitor to track memory usage, and did not notice a notable increase during the runs/sessions.
The freezes occur on several (but not all) machines that we tested on. The main computer that will be used to run the program is a Macbook Pro laptop, as well as a Mac mini, both of which exhibit the freezing problem. In my home lab, I have not been able to replicate the freezing issue on either a Mac or PC.
The freezing stops when I replace the
core.wait(). This isn’t a real solution for us however, because we need the
event.waitKeys() to help sync the program timing with our MRI, using the TTL pulses to trigger the start of the program (the TTL pulses are either a ‘t’ or a ‘5’ depending on the setup).
Does anybody know what could be causing this? Any help is greatly appreciated!
Here’s some sample code from the script in which the freezing occurs:
if calibrate_targ: calib_x = [l_marg, 0, r_marg, 0] calib_y = [0, t_marg, 0, b_marg] calib_text = 'You will now be presented with the target so that you will have an idea of what the image looks like in your peripheral vision. Please press %s to indicate that you have seen the target in each location. Press %s to begin.' % (response_key, response_key) inst_text.text = calib_text inst_text.draw() targ_image.image = image_fns[targ] win.flip() event.waitKeys(keyList = [response_key], clearEvents = True) targ_image.draw() win.flip() event.waitKeys(keyList = [response_key], clearEvents = True) for c in list(range(0, 4)): targ_image.pos = (calib_x[c], calib_y[c]) targ_image.draw() fix_circle.draw() fix_cross.draw() fix_dot.draw() win.flip() event.waitKeys(keyList = [response_key], clearEvents = True) win.flip()
Here’s a google drive .zip with the full script, images, and environment info: