Skip to content

Commit

Permalink
Merge branch 'respect_api_limits'
Browse files Browse the repository at this point in the history
  • Loading branch information
janfrederik committed Oct 16, 2021
2 parents 8e8f8da + ddbe342 commit c1f7de3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions exactonline/api/autorefresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Autorefresh(object):
If we still get a 401, we'll _also_ do a token refresh and hope that the
disagreement between us and the server gets resolved.
"""
def rest(self, request):
def raw_rest(self, request):
# Check how much time we have left, and refresh token 30 seconds before
# it expires.
have_fresh_token = False
Expand All @@ -48,7 +48,7 @@ def rest(self, request):
have_fresh_token = True

try:
decoded = super(Autorefresh, self).rest(request)
response = super(Autorefresh, self).raw_rest(request)
except HTTPError as e:
if e.code == 401 and not have_fresh_token:
# If we received a 401 even though we think our token is
Expand All @@ -58,9 +58,9 @@ def rest(self, request):
self.refresh_token()

# Retry the call but don't catch additional 401s.
decoded = super(Autorefresh, self).rest(request)
response = super(Autorefresh, self).raw_rest(request)

else:
raise

return decoded
return response

0 comments on commit c1f7de3

Please sign in to comment.