Blender how to periodically reload file (python)
Quote from the api documentation


  Python threading with Blender only works properly when the threads finish up before the script does




There are two ways i know of to periodically run python code:

Register a handler for scene_update_post:

import bpy
import time

t = [0.0] * 3
t[0] = time.time()
handles = bpy.app.handlers.scene_update_post

@persistent
def on_scene_update(scene):
    t[1] = time.time()
    t[2]+= t[1] - t[0]
    t[0] = t[1]
    print("Time elapsed %f" % t[2])

    if t[2] &gt; 20.0:
        handles.remove(on_scene_update)

handles.append(on_scene_update) 


Use a modal operator (in this case the code only runs when the user interacts with blender):

import bpy
import time

class OT_INFO_time_elapsed(bpy.types.Operator):
    bl_idname = "info.time_elapsed"
    bl_label = "Print elapsed time to the console"
    bl_options = set()

    def invoke(self, context, event):
        self.current = time.time()
        self.prev = self.current
        self.elapsed = 0.0
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def modal(self, context, event):
        self.current = time.time()
        self.elapsed += self.current - self.prev
        self.prev = self.current
        print("Time elapsed: %f" % self.elapsed)            
        return {'PASS_THROUGH'}

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

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

if __name__ == "__main__":
    register()




Since you intend to reload the file only the handler using the @persistent decorator will work.