Merge pull request #547 from CartoDB/development

Release python-0.21.2
This commit is contained in:
Javier Goizueta 2019-03-04 18:48:55 +01:00 committed by GitHub
commit 885c7c50fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -1,3 +1,8 @@
Mar 4th, 2019
==============
* Version `0.21.2` of the python library
* Fixed TomTom Qps respondes (#546)
Feb 25th, 2019
==============
* Version `0.26.2` of the client extension

View File

@ -2,13 +2,17 @@ import time
import random
from datetime import datetime
from exceptions import TimeoutException
import re
DEFAULT_RETRY_TIMEOUT = 60
DEFAULT_QUERIES_PER_SECOND = 10
TOMTOM_403_RATE_LIMIT_HEADER = 'Account Over Queries Per Second Limit'
TOMTOM_403_RATE_LIMIT_HEADERS = [
'Account Over Queries Per Second Limit',
'Developer Over Qps'
]
TOMTOM_DETAIL_HEADER = 'X-Error-Detail-Header'
TOMTOM_403_RATE_LIMIT_HEADER_PATTERN = re.compile('|'.join(TOMTOM_403_RATE_LIMIT_HEADERS), re.IGNORECASE)
def qps_retry(original_function=None, **options):
""" Query Per Second retry decorator
@ -49,9 +53,11 @@ 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:
detail_header = response.headers.get(TOMTOM_DETAIL_HEADER)
if detail_header and TOMTOM_403_RATE_LIMIT_HEADER_PATTERN.search(detail_header):
self.retry(start_time, attempt_number)
else:
raise e
self.retry(start_time, attempt_number)
elif response.status_code == 429:
self.retry(start_time, attempt_number)
else:

View File

@ -10,7 +10,7 @@ from setuptools import setup, find_packages
setup(
name='cartodb_services',
version='0.21.1',
version='0.21.2',
description='CartoDB Services API Python Library',