Can pan/tilt be blocking?

I am testing my pan/tilt shield and have a couple of issues. In the code segment below, I tell it to pan - 5 degrees in 2 seconds and then I read the position.

Pan.angle(-5,2000)
current_pan = Pan.angle()
print (“Current pan angle is %s” % current_pan)

What happens is that the code does not wait for the servo to get to 5 degrees. It sends the command and then prints the position almost right away.

Question: Can I use a wait or do loop after issuing Pan.angle(-5,2000) to not move forward in the code until the movement is finished?

Just add sleep(2000) after the command.

That does not work.

Why not ?

This code seems to work.

print(“1. Pan angle 0”)

Pan.angle(0)
utime.sleep_ms(5000)

print(“2. Pan angle -10”)
Pan.angle(-10)
utime.sleep_ms(5000)

print(“3. Pan angle 10”)
Pan.angle(10,2000)
utime.sleep_ms(5000)

print (“Done”)

For some reason, I have much better success with utime.sleep_ms() than I had with time.sleep().