Bug ? starting timer in load_post handler does not work

blender 2.8

there is the new timer api.

I CAN start the timer with a button (operator) call !

but NOT from load-post hander (in addon) !

# does not work: 
def timer_fired():
   # do stuff
   return 0.5 # seconds 

def handler():
    bpy.app.timers .register( timer_fired )
def my_register():
   bpy.app.handlers .load_post .append( handler )

@jacqueslucke, any idea?

Maybe the timer has to be marked as persistent.


(nevertheless this should not be necessary in load_post handler, will check it)

Quick update: You have to make the handler and the timer persistent currently.

that’s it – thank you !

# solution: make it persistent 

from bpy.app.handlers import persistent

@persistent   # do not discard, when file changes 
def timer_fired():
   # do stuff
   return 0.5 # seconds 

def handler_load_post():
   if not bpy.app.timers  .is_registered( timer_fired ):
       bpy.app.timers .register( timer_fired, first_interval=1.0, persistent=True )
def my_init():
   bpy.app.handlers .load_post .append( handler_load_post )