Skip to content

Commit

Permalink
Merge pull request #24 from NYPL/SCC-3775/get-request-retries
Browse files Browse the repository at this point in the history
fix logging spacing
  • Loading branch information
charmingduchess authored Nov 20, 2023
2 parents 92f9d7a + f8b08b8 commit 79b6d1b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/nypl_py_utils/classes/oauth2_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ def get(self, request_path, **kwargs):
resp.message = 'Oauth2 Client: Bad response from OauthClient'
resp.status_code = 500
self.logger.warning(f'Get request using path {request_path} \
returned response text:\n{resp.text}')
returned response text:\n{resp.text}')
# if client has specified that we want to retry failed requests and
# we haven't hit max retries
if self.with_retries is True:
retries = kwargs.get('retries', 0) + 1
if retries < 3:
self.logger.warning(
f'Retrying get request due to empty response from\
Oauth2 Client using path: {request_path}. \
Retry #{retries}')
Oauth2 Client using path: {request_path}. Retry #{retries}')
sleep(pow(2, retries - 1))
kwargs['retries'] = retries
# try request again
Expand Down

0 comments on commit 79b6d1b

Please sign in to comment.