From 21ecd059bfe7dde456e5d511c2bb0e45ba399339 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 19 Jan 2021 09:33:13 -0500 Subject: [PATCH] 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 --- pyghmi/ipmi/oem/lenovo/imm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 2d680264..94887681 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -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