From 2953fda75cfd18cc29e85d1408b5588bbb0abe0c Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Mon, 12 Dec 2016 12:14:10 +0100 Subject: [PATCH 1/3] Revert num of isochrone retries to 3 See #317 --- .../cartodb_services/cartodb_services/mapzen/isochrones.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py index 3fa72cd..1e94b32 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py @@ -13,7 +13,7 @@ class MapzenIsochrones: BASE_URL = 'https://matrix.mapzen.com/isochrone' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 1 + MAX_RETRIES = 3 ACCEPTED_MODES = { "walk": "pedestrian", From 79fb7961802a15effdad772861d94350808793e7 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Tue, 13 Dec 2016 10:07:10 +0100 Subject: [PATCH 2/3] Fix bug in retries usage; mantain behaviour The number of retries was being passed as the pool size parameter. This is corrected but number of retries changed to 1 to maintain previous behaviour. --- .../python/cartodb_services/cartodb_services/here/geocoder.py | 4 ++-- .../python/cartodb_services/cartodb_services/here/routing.py | 4 ++-- .../cartodb_services/cartodb_services/mapzen/geocoder.py | 4 ++-- .../cartodb_services/cartodb_services/mapzen/isochrones.py | 4 ++-- .../cartodb_services/cartodb_services/mapzen/routing.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py index 6aa743b..b8a83aa 100644 --- a/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py @@ -18,7 +18,7 @@ class HereMapsGeocoder(Traceable): DEFAULT_GEN = 9 READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES=3 + MAX_RETRIES=0 ADDRESS_PARAMS = [ 'city', @@ -92,7 +92,7 @@ class HereMapsGeocoder(Traceable): request_params.update(params) # TODO Extract HTTP client wrapper session = requests.Session() - session.mount(self.host, HTTPAdapter(self.MAX_RETRIES)) + session.mount(self.host, HTTPAdapter(max_retries=self.MAX_RETRIES)) response = session.get(self.host, params=request_params, timeout=(self.CONNECT_TIMEOUT, self.READ_TIMEOUT)) self.add_response_data(response, self._logger) diff --git a/server/lib/python/cartodb_services/cartodb_services/here/routing.py b/server/lib/python/cartodb_services/cartodb_services/here/routing.py index eed7835..b6db071 100644 --- a/server/lib/python/cartodb_services/cartodb_services/here/routing.py +++ b/server/lib/python/cartodb_services/cartodb_services/here/routing.py @@ -14,7 +14,7 @@ class HereMapsRoutingIsoline(Traceable): ISOLINE_PATH = '/routing/7.2/calculateisoline.json' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 3 + MAX_RETRIES = 0 ACCEPTED_MODES = { "walk": "pedestrian", @@ -57,7 +57,7 @@ class HereMapsRoutingIsoline(Traceable): parsed_options) # TODO Extract HTTP client wrapper session = requests.Session() - session.mount(self._url, HTTPAdapter(self.MAX_RETRIES)) + session.mount(self._url, HTTPAdapter(max_retries=self.MAX_RETRIES)) response = requests.get(self._url, params=request_params, timeout=(self.CONNECT_TIMEOUT, self.READ_TIMEOUT)) self.add_response_data(response, self._logger) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py index efb49e3..40c2351 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py @@ -15,7 +15,7 @@ class MapzenGeocoder(Traceable): BASE_URL = 'https://search.mapzen.com/v1/search' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 3 + MAX_RETRIES = 0 def __init__(self, app_key, logger, base_url=BASE_URL): self._app_key = app_key @@ -31,7 +31,7 @@ class MapzenGeocoder(Traceable): try: # TODO Extract HTTP client wrapper session = requests.Session() - session.mount(self._url, HTTPAdapter(self.MAX_RETRIES)) + session.mount(self._url, HTTPAdapter(max_retries=self.MAX_RETRIES)) response = session.get(self._url, params=request_params, timeout=(self.CONNECT_TIMEOUT, self.READ_TIMEOUT)) self.add_response_data(response, self._logger) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py index 1e94b32..295b146 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py @@ -13,7 +13,7 @@ class MapzenIsochrones: BASE_URL = 'https://matrix.mapzen.com/isochrone' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 3 + MAX_RETRIES = 0 ACCEPTED_MODES = { "walk": "pedestrian", @@ -32,7 +32,7 @@ class MapzenIsochrones: try: # TODO Extract HTTP client wrapper session = requests.Session() - session.mount(self._url, HTTPAdapter(self.MAX_RETRIES)) + session.mount(self._url, HTTPAdapter(max_retries=self.MAX_RETRIES)) response = session.get(self._url, params=request_params, timeout=(self.CONNECT_TIMEOUT, self.READ_TIMEOUT)) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py index 808e53f..af372c3 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py @@ -15,7 +15,7 @@ class MapzenRouting(Traceable): PRODUCTION_ROUTING_BASE_URL = 'https://valhalla.mapzen.com/route' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES=3 + MAX_RETRIES=0 ACCEPTED_MODES = { "walk": "pedestrian", @@ -50,7 +50,7 @@ class MapzenRouting(Traceable): request_params = self.__parse_request_parameters(json_request_params) # TODO Extract HTTP client wrapper session = requests.Session() - session.mount(self._url, HTTPAdapter(self.MAX_RETRIES)) + session.mount(self._url, HTTPAdapter(max_retries=self.MAX_RETRIES)) response = session.get(self._url, params=request_params, timeout=(self.CONNECT_TIMEOUT, self.READ_TIMEOUT)) self.add_response_data(response, self._logger) From 1f53af65b91eda186a6fb9b19c724cead62719d3 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Tue, 13 Dec 2016 11:32:22 +0100 Subject: [PATCH 3/3] Set number of http connection retries to 1 Change the maximum number of retries for connection to external services to 1. --- .../python/cartodb_services/cartodb_services/here/geocoder.py | 2 +- .../python/cartodb_services/cartodb_services/here/routing.py | 2 +- .../python/cartodb_services/cartodb_services/mapzen/geocoder.py | 2 +- .../cartodb_services/cartodb_services/mapzen/isochrones.py | 2 +- .../python/cartodb_services/cartodb_services/mapzen/routing.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py index b8a83aa..a3eb805 100644 --- a/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/here/geocoder.py @@ -18,7 +18,7 @@ class HereMapsGeocoder(Traceable): DEFAULT_GEN = 9 READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES=0 + MAX_RETRIES=1 ADDRESS_PARAMS = [ 'city', diff --git a/server/lib/python/cartodb_services/cartodb_services/here/routing.py b/server/lib/python/cartodb_services/cartodb_services/here/routing.py index b6db071..3a04a3a 100644 --- a/server/lib/python/cartodb_services/cartodb_services/here/routing.py +++ b/server/lib/python/cartodb_services/cartodb_services/here/routing.py @@ -14,7 +14,7 @@ class HereMapsRoutingIsoline(Traceable): ISOLINE_PATH = '/routing/7.2/calculateisoline.json' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 0 + MAX_RETRIES = 1 ACCEPTED_MODES = { "walk": "pedestrian", diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py index 40c2351..1209388 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py @@ -15,7 +15,7 @@ class MapzenGeocoder(Traceable): BASE_URL = 'https://search.mapzen.com/v1/search' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 0 + MAX_RETRIES = 1 def __init__(self, app_key, logger, base_url=BASE_URL): self._app_key = app_key diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py index 295b146..f7f15fd 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/isochrones.py @@ -13,7 +13,7 @@ class MapzenIsochrones: BASE_URL = 'https://matrix.mapzen.com/isochrone' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES = 0 + MAX_RETRIES = 1 ACCEPTED_MODES = { "walk": "pedestrian", diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py index af372c3..0cb0c80 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py @@ -15,7 +15,7 @@ class MapzenRouting(Traceable): PRODUCTION_ROUTING_BASE_URL = 'https://valhalla.mapzen.com/route' READ_TIMEOUT = 60 CONNECT_TIMEOUT = 10 - MAX_RETRIES=0 + MAX_RETRIES=1 ACCEPTED_MODES = { "walk": "pedestrian",