From c23a57c03f84ddd4ebb50a97e594021cb21a91c8 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Fri, 29 Jul 2016 16:22:34 +0200 Subject: [PATCH] Add QPS retry for mapzen isolines and add the 504 error to retry --- .../cartodb_services/cartodb_services/mapzen/matrix_client.py | 2 ++ .../lib/python/cartodb_services/cartodb_services/mapzen/qps.py | 2 +- server/lib/python/cartodb_services/setup.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/matrix_client.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/matrix_client.py index 9b4df53..bf72782 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/matrix_client.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/matrix_client.py @@ -1,5 +1,6 @@ import requests import json +from qps import qps_retry class MatrixClient: @@ -30,6 +31,7 @@ class MatrixClient: Returns: A dict with one_to_many, units and locations """ + @qps_retry def one_to_many(self, locations, costing): request_params = { 'json': json.dumps({'locations': locations}), diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py index fe8ebb2..fb32aa9 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py @@ -26,7 +26,7 @@ class QPSService: try: return fn(*args, **kwargs) except Exception as e: - if hasattr(e, 'response') and e.response.status_code == 429: + if hasattr(e, 'response') and (e.response.status_code == 429 or e.response.status_code == 504): self.retry(start_time, attempt_number) else: raise e diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index 5155d4e..f87881f 100644 --- a/server/lib/python/cartodb_services/setup.py +++ b/server/lib/python/cartodb_services/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='cartodb_services', - version='0.7.2.2', + version='0.7.2.3', description='CartoDB Services API Python Library',