Hello, i developed an addon with the use of bpy.msgbus.subscribe_rna like a handler to call a function in my script whenever a specified property, in this case whenever the render engine changes, changes.
My question is how can i make it persistent like it is used to do with the handlers? Adding @persistent above the function that gets called DOESN’T make it persistent.
Here are the pieces of code:
# some code # function that gets called whenever the render engine changes @persistent def function(*args): print("Test") # other code def register(): # registering some classes here # definition msgbus to update the function whenever the render engine updates subscribe_to = bpy.types.RenderSettings, "engine" bpy.types.Scene.something = object() bpy.msgbus.subscribe_rna( key = subscribe_to, owner = bpy.types.Scene.something, args = (), notify = function )
This is what the terminal prints after i:
- Created a project, enabled my addon and here the msgbus was working
- Saved the preferences with the addon enabled, saved the blend file and closed Blender
- Then i reopened the blend file (and the addon was enabled as i saved the preferences before), but now the msgbus is not working anymore