Rendering multiple scenes (openGL) comes with an annoying complexity.

Long story short:
I’ve created a script that allows for me to OpenGL render multiple scenes ( in a single blender file ) at a specified frame.
Although I update the “current_frame” of the scene that is about to get rendered. It always renders my previously rendered frame in scenes that are NOT my active scene.

For instance:

  1. I render frame 0 for scene A and B
    result 1: I receive files A0 and B0

  2. NEXT I render frame 1 for scene A and B
    result 2: I receive files A1 and B0

  3. NEXT I render frame 20 for scene A and B
    result 3: I receive files A20 and B1

Every scene that is rendered is rendered using the exact same code:

 def Render(self, frame , directory):        
        print("Rendering %s at frame %s" %(self.SceneName , frame))
            # swap screen to other scene ( for context sensitive stuff )
        previousSceneName = bpy.context.screen.scene.name
        bpy.context.screen.scene = bpy.data.scenes[self.SceneName]


            # set the scene' frame to the correct frame
        bpy.data.scenes[self.SceneName].frame_current = frame
        
            # get save file path
        batchFilePath = self.GetFilePath( frame, directory )
        self.FilePath = batchFilePath
        
            # render scene in openGL
        bpy.ops.render.opengl()
            # savce render
        bpy.data.images['Render Result'].save_render( batchFilePath )    
        print("-- Saved files to %s" %(batchFilePath)) 
        
            # back to old scene
        bpy.context.screen.scene = bpy.data.scenes[previousSceneName]

What am i forgetting?

PS: I tried adding a sleep tick before the render to allow for blender to catch up with the script once. But to no avail.

how about using an override?

http://www.blender.org/documentation/blender_python_api_2_69_1/bpy.ops.html#overriding-context