AttributeError: 'NoneType' object has no attribute 'send' pigpiod
Your problem is that you are calling pi.stop in the middle of your task.

"Stop" doesn't mean "stop the servo from moving."

It means "stop and close the connection to the pigpio service."

So, you call stop in the middle of your task and then try to send commands over the closed connection.  It has been closed and disposed of, so an attempt to access it returns an object of type "None" which (of course) doesn't have a "send" method.

Stop using "stop" except at the end when your program no longer needs the pigpio object.