Skip to content

Commit

Permalink
Revert "Retry when rate limited retrieving access token in tests"
Browse files Browse the repository at this point in the history
This reverts commit 6c0aacb.
  • Loading branch information
bryantgray committed Oct 30, 2024
1 parent b45ce02 commit d9e4ae3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
9 changes: 0 additions & 9 deletions tap_square/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import urllib.parse

from square.client import Client
from square.exceptions.api_exception import APIException
from singer import utils
import singer
import requests
Expand Down Expand Up @@ -55,14 +54,6 @@ def __init__(self, config):
self._access_token = self._get_access_token()
self._client = Client(access_token=self._access_token, environment=self._environment)

@backoff.on_exception(
backoff.expo,
(RetryableError, APIException),
max_time=180, # seconds
giveup=should_not_retry,
on_backoff=log_backoff,
jitter=backoff.full_jitter,
)
def _get_access_token(self):
body = {
'client_id': self._client_id,
Expand Down
14 changes: 2 additions & 12 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import backoff
import singer
from square.client import Client
from square.exceptions.api_exception import APIException


LOGGER = singer.get_logger()

Expand Down Expand Up @@ -103,13 +103,6 @@ def __init__(self, env):
self._access_token = self._get_access_token()
self._client = Client(access_token=self._access_token, environment=self._environment)

@backoff.on_exception(
backoff.expo,
(RetryableError, APIException),
max_time=180,
on_backoff=log_backoff,
jitter=backoff.full_jitter,
)
def _get_access_token(self):
body = {
'client_id': self._client_id,
Expand All @@ -125,10 +118,7 @@ def _get_access_token(self):

if result.is_error():
error_message = result.errors if result.errors else result.body
if 'Service Unavailable' in error_message or 'upstream connect error or disconnect/reset before headers' in error_message or result.status_code == 429:
raise RetryableError(error_message)
else:
raise RuntimeError(error_message)
raise RuntimeError(error_message)

return result.body['access_token']

Expand Down

0 comments on commit d9e4ae3

Please sign in to comment.