Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backoff for RemoteDisconnect and ConnectionError #15

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tap_xero/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import pytz
import backoff
import singer
from http.client import RemoteDisconnected
from requests.exceptions import ConnectionError,ReadTimeout,ChunkedEncodingError
from urllib3.exceptions import ProtocolError

LOGGER = singer.get_logger()

Expand Down Expand Up @@ -212,7 +215,7 @@ def refresh_credentials(self, config, config_path):
self.tenant_id = config['tenant_id']


@backoff.on_exception(backoff.expo, (json.decoder.JSONDecodeError, XeroInternalError), max_tries=3)
@backoff.on_exception(backoff.expo, (json.decoder.JSONDecodeError, XeroInternalError,RemoteDisconnected,ConnectionError,ReadTimeout,ChunkedEncodingError,ProtocolError), max_tries=3)
@backoff.on_exception(retry_after_wait_gen, XeroTooManyInMinuteError, giveup=is_not_status_code_fn([429]), jitter=None, max_tries=3)
def check_platform_access(self, config, config_path):

Expand All @@ -234,7 +237,7 @@ def check_platform_access(self, config, config_path):
raise_for_error(response)


@backoff.on_exception(backoff.expo, (json.decoder.JSONDecodeError, XeroInternalError), max_tries=3)
@backoff.on_exception(backoff.expo, (json.decoder.JSONDecodeError, XeroInternalError,RemoteDisconnected,ConnectionError,ReadTimeout,ChunkedEncodingError,ProtocolError), max_tries=3)
@backoff.on_exception(retry_after_wait_gen, XeroTooManyInMinuteError, giveup=is_not_status_code_fn([429]), jitter=None, max_tries=3)
def filter(self, tap_stream_id, since=None, **params):
xero_resource_name = tap_stream_id.title().replace("_", "")
Expand Down
5 changes: 4 additions & 1 deletion tap_xero/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from dateutil.parser import parse
from dateutil.relativedelta import relativedelta
from tap_xero.client import XeroUnauthorizedError
from http.client import RemoteDisconnected
from requests.exceptions import ConnectionError,ReadTimeout,ChunkedEncodingError
from urllib3.exceptions import ProtocolError


LOGGER = singer.get_logger()
Expand All @@ -33,7 +36,7 @@ class RateLimitException(Exception):


@backoff.on_exception(backoff.expo,
RateLimitException,
(RateLimitException,RemoteDisconnected,ConnectionError,ReadTimeout,ChunkedEncodingError,ProtocolError),
max_tries=10,
factor=2)
def _make_request(ctx, tap_stream_id, filter_options=None, attempts=0):
Expand Down