Calling an Operator from a timer

I have been researching what is possible with timers, but have found some limitations. The main one being you cannot get access to many of the properties in bpy.context, and if you try to call an operator from the timer function it fails saying window is not found in context.

I am curios to know what other devs are using timers for. There are good examples here, but it doesn’t explain any real world use cases.

you can override the context of an operator when you call it

Yeah I have tried that, and it works when Blender first starts, but the second time the timer is called i get this and Blender crashes.

Address : 0x00007FF6C0D78150
Module : d:\blender28source\build_windows_Full_x64_vc15_Release\bin\Release\blender.exe
The terminal process terminated with exit code: 11

The operator only has a print statement letting me know that it is executed, so there shouldn’t be an issue there.

I think that’s the question that should be asked/answered, you shouldn’t be getting an access violation simply for calling an operator via a timer. seems like a legitimate bug to me, can you put together a minimum repro example that can be verified?

Perhaps it would help if you post your exact code, or the operator you’re trying to call in your timer. The following example code works just fine, for example:

import bpy

def main(context):

class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    def execute(self, context):
        return {'FINISHED'}

def test():    
    return 10.0

def register():

def unregister():

if __name__ == "__main__":
1 Like

@Andrew_Peel Actually, I’ve just confirmed that this is a bug- the code I posted works fine on a build from a week ago, but with the latest nightly it crashes with an access violation. When I get back to my other workstation I’ll get the build number for the last version it worked correctly and post it here- this should definitely be reported on the bug tracker.

Edit: bug posted here:

Thank you so much for helping verifying this as a bug and creating a bug report. I have tested this with the latest build and everything is working as expected.