diff --git a/server/lib/python/cartodb_services/cartodb_services/tools/qps.py b/server/lib/python/cartodb_services/cartodb_services/tools/qps.py index 24d110e..9ae3abd 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tools/qps.py +++ b/server/lib/python/cartodb_services/cartodb_services/tools/qps.py @@ -6,6 +6,9 @@ from exceptions import TimeoutException DEFAULT_RETRY_TIMEOUT = 60 DEFAULT_QUERIES_PER_SECOND = 10 +TOMTOM_403_RATE_LIMIT_HEADER = 'Account Over Queries Per Second Limit' +TOMTOM_DETAIL_HEADER = 'X-Error-Detail-Header' + def qps_retry(original_function=None, **options): """ Query Per Second retry decorator @@ -46,6 +49,8 @@ class QPSService: response = getattr(e, 'response', None) if response is not None: if self._provider is not None and self._provider == 'tomtom' and (response.status_code == 403): + if response.headers.get(TOMTOM_DETAIL_HEADER) != TOMTOM_403_RATE_LIMIT_HEADER: + raise e self.retry(start_time, attempt_number) elif response.status_code == 429: self.retry(start_time, attempt_number)