How do you clear all timers in
bpy.app.timers? It seems like there is no straightforward way, if not impossible, to clear timers that have run from previous script execution. It is easy to do for
bpy.app.handlers, you just call the
clear() function of the handler.
import bpy bpy.app.handlers.frame_change_post.clear() # easy clear everything from previous execution as well bpy.app.timers.clear() # but this does not exist def some_handler(scene, depsgraph): print("some_handler", scene, depsgraph) def some_timer(): print("some_timer") return 2.0 bpy.app.handlers.frame_change_post.append(some_handler) bpy.app.timers.register(some_timer)
And of course you can't clear a previous
some_timer function using
bpy.app.timers.unregister(some_timer) from a previous execution because that function will have another pointer address
<function some_timer at 0x00000000XXXXXXXX>
Current workaround is to close the file and re-open the file or open a new one. Is there any fix or any other workaround for this so I don't have to close the file?