expInfo['frameRate'] is sometimes "None" for no apparent reason

I’m coding an experiment that sets the timing of stimuli presentation in frames based on the refresh rate of the monitor, like this:

mask_start = int(1000 / (1000/ expInfo[‘frameRate’]))

Sometimes, this works fine and the experiment runs with no issues. Other times, the experiment will crash, giving me this error:

TypeError: unsupported operand type(s) for /: ‘int’ and ‘NoneType’

In those instances, a print statement confirms that expInfo[‘frameRate’] is “None” (when the experiment runs, the correct refresh rate is printed). I am confused about this because whether the experiment crashes or not has nothing to do with anything I change; when it crashes like this, I just try to run it again and it will run properly within a couple of tries. Is there any way to get this to work more consistently?