Skip to content
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
8 changes: 7 additions & 1 deletion domaintools/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
filter_by_field,
DTResultFilter,
)
from domaintools.exceptions import ServiceUnavailableException, ServiceException
from domaintools.utils import validate_feeds_parameters


Expand Down Expand Up @@ -163,7 +164,12 @@ def _results(self, product, path, cls=Results, **kwargs):
if product != "account-information" and self.rate_limit and not self.limits_set and not self.limits:
always_sign_api_key_previous_value = self.always_sign_api_key
header_authentication_previous_value = self.header_authentication
self._rate_limit(product)
try:
self._rate_limit(product)
except (ServiceUnavailableException, ServiceException):
# If account_information fails (e.g. rate limited itself),
# skip client-side rate limiting and proceed with the original call.
self.limits_set = True
# Reset always_sign_api_key and header_authentication to its original
# User-set values as these might be affected when self.account_information() was executed
self.always_sign_api_key = always_sign_api_key_previous_value
Expand Down
2 changes: 1 addition & 1 deletion domaintools/base_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _get_results(self):
wait_for = self._wait_time()
if self.api.rate_limit and (wait_for is None or self.product == "account-information"):
data = self._make_request()
if data.status_code == 503: # pragma: no cover
if data.status_code == 503 and self.product != "account-information": # pragma: no cover
sleeptime = 60
log.info(
"503 encountered for [%s] - sleeping [%s] seconds before retrying request.",
Expand Down
Loading