Commit 233812094961ae2990151234fde8e10c8443ed18
1 parent
78eb2a62
Exists in
master
Skip repeated failures gracefully.
Showing
1 changed file
with
9 additions
and
0 deletions
Show diff stats
flaskr/controllers/main_controller.py
... | ... | @@ -269,6 +269,7 @@ def compute(): # process the queue of estimation requests |
269 | 269 | estimation.public_id |
270 | 270 | ) |
271 | 271 | |
272 | + failed_addresses = [] | |
272 | 273 | geocoder = CachedGeocoder() |
273 | 274 | |
274 | 275 | # GEOCODE ORIGINS ######################################################### |
... | ... | @@ -279,6 +280,8 @@ def compute(): # process the queue of estimation requests |
279 | 280 | for i in range(len(origins_addresses)): |
280 | 281 | |
281 | 282 | origin_address = origins_addresses[i].strip() |
283 | + if origin_address in failed_addresses: | |
284 | + continue | |
282 | 285 | |
283 | 286 | try: |
284 | 287 | origin = geocoder.geocode(origin_address.encode('utf-8')) |
... | ... | @@ -287,6 +290,7 @@ def compute(): # process the queue of estimation requests |
287 | 290 | origin_address, e, |
288 | 291 | ) |
289 | 292 | _handle_warning(estimation, response) |
293 | + failed_addresses.append(origin_address) | |
290 | 294 | continue |
291 | 295 | |
292 | 296 | if origin is None: |
... | ... | @@ -294,6 +298,7 @@ def compute(): # process the queue of estimation requests |
294 | 298 | origin_address, |
295 | 299 | ) |
296 | 300 | _handle_warning(estimation, response) |
301 | + failed_addresses.append(origin_address) | |
297 | 302 | continue |
298 | 303 | |
299 | 304 | origins.append(origin) |
... | ... | @@ -311,6 +316,8 @@ def compute(): # process the queue of estimation requests |
311 | 316 | for i in range(len(destinations_addresses)): |
312 | 317 | |
313 | 318 | destination_address = destinations_addresses[i].strip() |
319 | + if destination_address in failed_addresses: | |
320 | + continue | |
314 | 321 | |
315 | 322 | try: |
316 | 323 | destination = geocoder.geocode(destination_address.encode('utf-8')) |
... | ... | @@ -319,6 +326,7 @@ def compute(): # process the queue of estimation requests |
319 | 326 | destination_address, e, |
320 | 327 | ) |
321 | 328 | _handle_warning(estimation, response) |
329 | + failed_addresses.append(destination_address) | |
322 | 330 | continue |
323 | 331 | |
324 | 332 | if destination is None: |
... | ... | @@ -326,6 +334,7 @@ def compute(): # process the queue of estimation requests |
326 | 334 | destination_address, |
327 | 335 | ) |
328 | 336 | _handle_warning(estimation, response) |
337 | + failed_addresses.append(destination_address) | |
329 | 338 | continue |
330 | 339 | |
331 | 340 | # print(repr(destination.raw)) | ... | ... |