commit
909554b453
@ -70,7 +70,7 @@ class TomTomGeocoder(Traceable):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@qps_retry(qps=5)
|
@qps_retry(qps=5, provider='tomtom')
|
||||||
def geocode(self, searchtext, city=None, state_province=None,
|
def geocode(self, searchtext, city=None, state_province=None,
|
||||||
country=None):
|
country=None):
|
||||||
response = self.geocode_meta(searchtext, city, state_province, country)
|
response = self.geocode_meta(searchtext, city, state_province, country)
|
||||||
@ -80,7 +80,7 @@ class TomTomGeocoder(Traceable):
|
|||||||
else:
|
else:
|
||||||
return response[0]
|
return response[0]
|
||||||
|
|
||||||
@qps_retry(qps=5)
|
@qps_retry(qps=5, provider='tomtom')
|
||||||
def geocode_meta(self, searchtext, city=None, state_province=None,
|
def geocode_meta(self, searchtext, city=None, state_province=None,
|
||||||
country=None):
|
country=None):
|
||||||
if searchtext:
|
if searchtext:
|
||||||
|
@ -89,7 +89,7 @@ class TomTomRouting(Traceable):
|
|||||||
point[ENTRY_LONGITUDE]))
|
point[ENTRY_LONGITUDE]))
|
||||||
return geometry
|
return geometry
|
||||||
|
|
||||||
@qps_retry(qps=5)
|
@qps_retry(qps=5, provider='tomtom')
|
||||||
def directions(self, waypoints, profile=DEFAULT_PROFILE,
|
def directions(self, waypoints, profile=DEFAULT_PROFILE,
|
||||||
date_time=DEFAULT_DEPARTAT):
|
date_time=DEFAULT_DEPARTAT):
|
||||||
self._validate_profile(profile)
|
self._validate_profile(profile)
|
||||||
|
@ -6,6 +6,9 @@ from exceptions import TimeoutException
|
|||||||
DEFAULT_RETRY_TIMEOUT = 60
|
DEFAULT_RETRY_TIMEOUT = 60
|
||||||
DEFAULT_QUERIES_PER_SECOND = 10
|
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):
|
def qps_retry(original_function=None, **options):
|
||||||
""" Query Per Second retry decorator
|
""" Query Per Second retry decorator
|
||||||
@ -46,6 +49,8 @@ class QPSService:
|
|||||||
response = getattr(e, 'response', None)
|
response = getattr(e, 'response', None)
|
||||||
if response is not None:
|
if response is not None:
|
||||||
if self._provider is not None and self._provider == 'tomtom' and (response.status_code == 403):
|
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)
|
self.retry(start_time, attempt_number)
|
||||||
elif response.status_code == 429:
|
elif response.status_code == 429:
|
||||||
self.retry(start_time, attempt_number)
|
self.retry(start_time, attempt_number)
|
||||||
|
@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.20.1',
|
version='0.20.2',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user