Closed ljmc-github closed 2 years ago
My preference would be the former, it feels more Pythonic (Ask Forgiveness Not Permission) and would also cover any case where the token was invalid for any other reason.
You're right that there's no way to refresh an expired token, so the only option is to create a new session.
I agree on both AFNP and broarder recovery, I'll send a PR your way ASAP.
The helper as it is right now is not able to recover from expired token (>24h old).
I don't think there is a way to refresh token other than starting a new session and using this initial token.
I would like opinions about possible recovery/prevention methods:
First thought was a recovery method by adding a try/except block around update_config's
get_latest_configuration()
call to catch invalid tokens and start a fresh session.Second option would be preventive by adding a time check similar to the if time since update < polling time, but for time since update over 24h.
I know this is a rare case, but it happened to me in testing where the service was deployed and testers took over 24h to get to testing, which caused the service to be DOA according to them.