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:
parent
b6d95c4eef
commit
21ecd059bf
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user