When using an Operator Modal Timer, how do i change the time period such that it executes every 5 seconds? I'm trying to use a modal operator timer to get a piece of code to execute every 5 seconds. Currently all i want is for it to print a statement every 5 seconds however, in the future, this will be changed to create a new object every 5 seconds.
Currently i use the following which prints the statement multiple times a second.
import bpy


class ModalTimerOperator(bpy.types.Operator):
    &quot;&quot;&quot;Operator which runs its self from a timer&quot;&quot;&quot;
    bl_idname = &quot;wm.modal_timer_operator&quot;
    bl_label = &quot;Modal Timer Operator&quot;

    _timer = None

    def modal(self, context, event):
        if event.type in {'RIGHTMOUSE', 'ESC'}:
            self.cancel(context)
            return {'CANCELLED'}

        if event.type == 'TIMER':
            print(&quot;5 seconds has passed&quot;)

        return {'PASS_THROUGH'}

    def execute(self, context):
        wm = context.window_manager
        self._timer = wm.event_timer_add(1.0, window=context.window)
        wm.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def cancel(self, context):
        wm = context.window_manager
        wm.event_timer_remove(self._timer)


def register():
    bpy.utils.register_class(ModalTimerOperator)


def unregister():
    bpy.utils.unregister_class(ModalTimerOperator)


if __name__ == &quot;__main__&quot;:
    register()

    # test call
    bpy.ops.wm.modal_timer_operator()


How do i change this to run once every 5 seconds?
The event timer has a property which defines how often your modal function will get called with the timer event, just change the value accordingly in the execute function:
time = 5.0
self._timer = wm.event_timer_add(time, window=context.window)