2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-29 12:27:37 +00:00

Retry cached data retrieval on 401

Under certain strain, we may unexpectedly
be logged out. Counteract through a single
retry, which seems to overwhelmingly
mitigate the issue.

Change-Id: Ibf72959988a2c143e5479f82db777b39cfa4a9a2
This commit is contained in:
Jarrod Johnson 2021-01-19 09:33:13 -05:00
parent b6d95c4eef
commit 21ecd059bf

View File

@ -405,7 +405,12 @@ class IMMClient(object):
def grab_cacheable_json(self, url, age=30):
data = self.get_cached_data(url, age)
if not data:
data = self.wc.grab_json_response(url)
data, status = self.wc.grab_json_response_with_status(url)
if status == 401:
self._wc = None
data, status = self.wc.grab_json_response_with_status(url)
if status != 200:
data = {}
self.datacache[url] = (data, util._monotonic_time())
return data