Snap FK IK and reverse with python scripting

I recently developed this little python script to use snap FK to IK and IK to FK.
Like this video example

Here the code and the blend file

I’m doing matrix equalities to be able to plate the bones one on top of the other.

However, when I want to make these matrix equalities my code becomes disgusting because I add a for loop with 4 or 15 iterations to refresh the bpy.ops.wm.redraw_timer() window depending on the type of snap.

I must be going about this the wrong way, but I find that my code is horribly constructed in this way.

With the rig I’ve created, is there a solution to avoid refreshing?

    def execute(self, context):
        for i in range(0, 4):
            bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
        return { 'FINISHED'}

My rig remains basically simple.
Is there another way to avoid these for loops with wm.redraw_timer?