0

EDIT: I've since taken a different approach with my task such that the solution to this isn't necessary anymore, but I'm leaving the question up for posterity. Because of this post (Manual pyglet loop freezes after a few iterations) describing a similar issue, I believe something inherent to pyglet was the issue. The solution recommended in the cited thread did not work for me.

Brand new to Python and PsychoPy. I inherited a script that will run a task, but we're encountering a major issue. The overview is that participants see a set of instructions, and then begin a loop in which they see background information about a movie clip, then watch that movie clip (using MovieStim3 and pyglet) while we collect live, ongoing ratings from them using a joystick, and then that loop continues to reiterate through the 9 stimuli.

The problem is that the script freezes on the 6th iteration of the for loop every time. It will play the video through and freeze on the last frame. The first five iterations will work perfectly, though, it seems. No error messages are produced and I have to force quit in order to get psychopy to close. It also fails to produce a log or any data.

Here's what I've tried so far that hasn't worked:

  • Changing the order of the films
  • Reducing all films to a length of 5s
  • Changing the films from .mp4 to .mov
  • Changing which films we show

I think an additional piece of information that's helpful to know is that if I reduce my stimuli list to 5 films, the script executes perfectly from start to finish. Naturally, I assumed that the person who originally coded this must have limited the number of possible iterations to 5, but neither they nor I can find such a parameter. Knowing this, I thought a simple solution might be to simply make two separate loops and two separate stimuli lists (both under 6 items) and have it iterate through those sequentially. However, I run into the exact same issue. This makes me think it's got to be something outside of my stimuli presentation loop, however, I'm simply at a loss to figure out what it might be. If anyone could offer any assistance or guidance, it would be immensely appreciated.

Because I can't isolate the problem to one area and there's a character limit here, I'm going to share the whole script and the associated stimuli via my github repository, but if there's anything more targeted that would be helpful for me to share here, please don't hesitate to ask me. I'm sure it's also very bulky code, so apologies for that as well. If you've gotten this far, thanks so much for your time.

  • I don't know anything about PsychoPy or Pyglet, but I see the application has logging already present. I strongly suggest you enable debug logging and then run the application to recreate the freeze event then read the logs to see if that reveals anything worthy of fixing. ```logFile = logging.LogFile(filename+'.log', level=logging.EXP) logging.console.setLevel(logging.WARNING) Change logging level to DEBUG.``` – Sn3akyP3t3 Aug 18 '21 at 03:26
  • Another idea perhaps would be to see if you can run the application with a debugger attached such as VS Code. This may not work at all, but its worth a try. Then you can set breakpoints and the code will essentially pause where your breakpoint is set and you can step forward until the freeze event occurs. The downside of this of course is that it may actually break the code in another way that's unexpected or it just may fix it because your introducing a slower processing rate which could be allowing resources to flush. I really don't know, but worth a shot. – Sn3akyP3t3 Aug 18 '21 at 03:38
  • You already committed the code to a repo so that's good, but if you start getting experimental make sure you use a version control and a sane branching strategy so you don't hate yourself later when you can't remember how the code was before you started trying to fix it. – Sn3akyP3t3 Aug 18 '21 at 03:41
  • I appreciate the thoughtful, detailed responses. I honestly had no idea how debugging worked in python. R Studio and Matlab have spoiled me. I'm going to try these out and see if I can get anything to budge. Thanks again! – William Mitchell Aug 19 '21 at 11:47

0 Answers0