In a project I have a very simple application handler that is executed when the current frame change:
import bpy def frame_handler(scene): print("Running frame handler version 1.") if frame_handler in bpy.app.handlers.frame_change_pre: print("Removing handler") bpy.app.handlers.frame_change_pre.remove(frame_handler) print("Adding handler") bpy.app.handlers.frame_change_pre.append(frame_handler) print("Number of handlers: " + str(len(bpy.app.handlers.frame_change_pre)))
Adding the handler works fine and it’s executed as expected. But let’s says I want to update my handler to version 2. If I change to the code and run it again I will now have two handlers. When the handler is executed I see that both the old and the new version was running.
In my script I have tried to detect and existing handler and remove it, but clearly that doesn’t work. How do I do that?
My best solution so far is to execute
bpy.app.handlers.frame_change_pre.clear() but that feels like cheating :-)
I’m using Blender 2.80 RC3.