Rotating the handles of bezier curves.
Running script in edit mode on default bez (blender 2.82)
There are some issues at play, eg what handle type you are using. I have set the type of both to
For example, here is a script to rotate both handles of point 0 of bezier curve by 45 degrees about the local z axis passing through the coordinate point.
Running the script 8 times should see the handles return to initial position.
To rotate have used one of the methods outlined in https://blender.stackexchange.com/a/7603/15543 which is probably a better way to go for a "Procedural System" than operators.
from mathutils import Matrix
from math import radians
ob = bpy.context.object
cu = ob.data
spline = cu.splines
p = spline.bezier_points
M = (Matrix.Translation(p.co) @
Matrix.Rotation(radians(45), 4, 'Z') @
p.handle_left_type = 'FREE'
p.handle_right_type = 'FREE'
p.handle_left = M @ p.handle_left
p.handle_right = M @ p.handle_right
Running the script in 2.81 in either mode produces the desired result and updates in the UI.
If you are having issues recommend that you look for errors in the system console, or IMO better still, test in the python console.
# this one throws a syntax error
# or this one relies on settings for axis an pivot point, but does rotate