From 5cacdcb0c4d3b16eac2407feec080cfeec8b0827 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Thu, 8 Jun 2023 01:03:55 +0400 Subject: [PATCH] Fix limits in georeverse.py --- src/main/georeverse.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/georeverse.py b/src/main/georeverse.py index 4ca8e10..d8693bc 100644 --- a/src/main/georeverse.py +++ b/src/main/georeverse.py @@ -1,12 +1,13 @@ from functools import partial from geopy import Nominatim +from geopy.extra.rate_limiter import RateLimiter class Georeverse: def __init__(self) -> None: geolocator: Nominatim = Nominatim(user_agent="MyApp") - self.__reverse = partial(geolocator.reverse, language="ru") + self.__reverse = RateLimiter(partial(geolocator.reverse, language="ru"), min_delay_seconds=1) def get_city(self, latitude: float, longitude: float) -> str: return self.__reverse(f'{latitude}, {longitude}')