|
@@ -26,7 +26,8 @@ def point_has_streetview(lat, lng):
|
|
|
|
|
|
|
|
|
class ExhaustedSourceError(Exception):
|
|
|
- pass
|
|
|
+ def __init__(self, partial=[]):
|
|
|
+ self.partial = partial
|
|
|
|
|
|
|
|
|
class GeoPointSource:
|
|
@@ -73,7 +74,10 @@ class CachedGeoPointSource(GeoPointSource):
|
|
|
n = n if n is not None else self.stock_target - len(self.stock)
|
|
|
if n > 0:
|
|
|
logger.info(f"Restocking {type(self).__name__} with {n} points")
|
|
|
- pts = self.source.get_points(n)
|
|
|
+ try:
|
|
|
+ pts = self.source.get_points(n)
|
|
|
+ except ExhaustedSourceError as e:
|
|
|
+ pts = e.partial # take what we can get
|
|
|
self.stock.extend(pts)
|
|
|
diff = n - len(pts)
|
|
|
if diff > 0:
|