Execute Python script between rendering animation frames I've attached a function to the frame change handler:

bpy.app.handlers.frame_change_pre.append(someFunc)


All works fine when I drag the slider on the Timeline. But when I render with the "Animation" button, it doesn't work. I found that:


Blender offers only a limited set of API functions while rendering. (See also the answer by Jerryno to another question: Accessing screen areas from render handler) Is there any form of documentation, why this is the case and which functions can be accessed while rendering, and which cannot?
Blender doesn't wait for a script updating the scene before it advances to render the next frame. Is there by chance a API call that makes Blender wait for a script to finish before rendering on?


If the answer to both questions is "no", is there maybe a script that offers animation rendering with manual frame advance, like this:


Render the first frame, apply postpro etc, write it to correct file
name  
Go back to the viewport, advance a frame
Render next frame, apply postpro* etc...


*With postpro(duction) I mean apply everything what the compositor would do in the the regular rendering pipeline, if compositing is switched on.
You can loop through frames and render each one and do whatever you want before rendering the next one like this:

import bpy

s=bpy.context.scene

s.render.resolution_x = 512 # just for my example
s.render.resolution_y = 512

for i in range(s.frame_start,s.frame_end):
    s.frame_current = i

    s.render.filepath = (
                        "C:\\temp\\" # some path
                        + str(s.frame_current ).zfill(3)
                        )
    bpy.ops.render.render( #{'dict': "override"},
                          #'INVOKE_DEFAULT',  
                          False,            # undo support
                          animation=False, 
                          write_still=True
                         )

    # Do whatever you want here
    # Changing render resolution is one of the things imposible to do with
    # handlers while rendering an animation so let's do that

    if s.render.resolution_y == 512:
        s.render.resolution_y = 256
    else:
        s.render.resolution_y = 512


The problems start if you want to see the render happening in the UI. If you uncomment 'INVOKE_DEFAULT' it breaks everytihing because the script is unable to know when the started render finishes. People have tried to work around that, but things get ugly from here. See this question if you want to pursue this.