Merge pull request #583 from CartoDB/tomtom_bulk_qps_retry

add qps_retry to tomtom bulk API calls
This commit is contained in:
Daniel G. Aubert 2020-03-06 10:29:34 +01:00 committed by GitHub
commit 151c768894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ from requests.adapters import HTTPAdapter
from cartodb_services import StreetPointBulkGeocoder from cartodb_services import StreetPointBulkGeocoder
from cartodb_services.geocoder import geocoder_error_response from cartodb_services.geocoder import geocoder_error_response
from cartodb_services.tomtom import TomTomGeocoder from cartodb_services.tomtom import TomTomGeocoder
from cartodb_services.tools.qps import qps_retry
from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools.exceptions import ServiceException
@ -59,6 +60,7 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
self._logger.error(msg, e) self._logger.error(msg, e)
return [geocoder_error_response(msg)] * len(searches) return [geocoder_error_response(msg)] * len(searches)
@qps_retry(qps=5, provider='tomtom')
def _send_batch(self, searches): def _send_batch(self, searches):
body = {'batchItems': [{'query': self._query(s)} for s in searches]} body = {'batchItems': [{'query': self._query(s)} for s in searches]}
request_params = { request_params = {
@ -76,6 +78,7 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
self._logger.error(msg) self._logger.error(msg)
raise ServiceException(msg, response) raise ServiceException(msg, response)
@qps_retry(qps=5, provider='tomtom')
def _download_results(self, location): def _download_results(self, location):
stalled_retries = 0 stalled_retries = 0
while True: while True: