Skip to content

Commit

Permalink
retry on keyerror during requests (#68)
Browse files Browse the repository at this point in the history
Pytest sometimes deletes PYTEST_CURRENT_TEST while requests
is calling urllib's getproxies_environment.
This should probably be fixed in urllib.
  • Loading branch information
Stefan Giroux authored Jun 18, 2022
1 parent fead072 commit 73fdfd9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testrail_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ def request(self, method: METHODS, src: str, raw: bool = False, **kwargs):
response = self.__session.request(
method=method.value, url=url, timeout=self.__timeout, **kwargs
)
except KeyError:
if count < self.__exc_iterations - 1:
logger.warning(
"KeyError, retrying %s/%s", count + 1, self.__exc_iterations
)
continue
else:
raise
except Exception as err:
logger.error("%s", err, exc_info=True)
raise
Expand Down

0 comments on commit 73fdfd9

Please sign in to comment.