How to force update the 3d view port in blender during python file execution
Found the answer, threading can be used

def my_timer():
    from threading import Timer
    main();
    #print(i);
    t = Timer(0.1, my_timer)
    t.start()


Hope this helps, we took a lot of time to come up with it