From d3eec57bff22a36ccbd9f074e6483104f8e92117 Mon Sep 17 00:00:00 2001 From: jiasli <4003950+jiasli@users.noreply.github.com> Date: Fri, 9 May 2025 11:56:34 +0800 Subject: [PATCH] binary_cache --- src/azure-cli-core/azure/cli/core/auth/binary_cache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/auth/binary_cache.py b/src/azure-cli-core/azure/cli/core/auth/binary_cache.py index 3f4832678fc..e56c95b130f 100644 --- a/src/azure-cli-core/azure/cli/core/auth/binary_cache.py +++ b/src/azure-cli-core/azure/cli/core/auth/binary_cache.py @@ -42,10 +42,11 @@ def load(self): logger.debug("load: %s", self.filename) try: self.data = self._load() - except (pickle.UnpicklingError, EOFError) as ex: - # We still get exception after retry: + except Exception as ex: # pylint: disable=broad-exception-caught + # If we still get exception after retry, ignore all types of exceptions and use a new cache. # - pickle.UnpicklingError is caused by corrupted cache file, perhaps due to concurrent writes. # - EOFError is caused by empty cache file created by other az instance, but hasn't been filled yet. + # - AttributeError is caused by reading cache generated by different MSAL versions. logger.debug("Failed to load cache: %s. Using a fresh one.", ex) self.data = {} # Ignore a non-existing or corrupted http_cache