Closed sdague closed 7 years ago
@sdague Thanks! I was just reading about decorators in Python. Then I saw you already started the "sketch". I will work on this and see if I can get it set up correctly. This definitely seems like a better alternative to my time.sleep(xx)
because like you said, sleeping doesn't go well with async. I will continue to work on this approach.
Awesome. Yeh, I mostly wanted to provide a starting point so that you wouldn't need to invent from whole cloth. Take this and modify it, or just use it for learning, however you want to run with it.
@sdague Please check out this implementation when time permits. I would definitely appreciate your feedback. I decided to raise a class specific 'APIError' to the calling program, e.g. home-assistant, therefore letting the originating program handle the error as it deems necessary.
This demonstrates using retry_login in the even that we get an error thrown during connectivity to ensure that we can roll over a unifi controller upgrade.
(This isn't tested, but is a quick sketch that "should" work)