Blender Python Console Commands not completing before next one is interpreted?
Ditch the operators and use the API

Example script, rotates object 90 degrees about z axis. Inserts all keyframes of active keying set at frame 30.  Not using any operators or changing the frame, simply set a property and call keyframe_insert.

import bpy
from mathutils import Matrix
from math import radians
context = bpy.context
ob = context.object
scene = context.scene
# emulate rotation op
R = Matrix.Rotation(radians(90), 4, 'Z') # rotate 90 about z axis
ob.matrix_world *= R

#emulate ops.anim.keyframe_insert
ks = scene.keying_sets.active
if ks:
    ks.refresh()
    for p in ks.paths:
        # check for entire array (index=-1)
        index = -1 if p.use_entire_array else p.array_index
        # insert keyframe
        ob.keyframe_insert(
                p.data_path, 
                index=index, 
                frame=30)


A method could be made using methods above that is passed the arguments object angle, axis and frame.

def rot_and_keyframe(ob, angle, axis, frame):
    ...

rot_and_keyframe(ob, radians(90), 'X', 30)
rot_and_keyframe(ob, radians(-90), 'Y', 60)