File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 88import redis
99import timezonefinder # type: ignore[import-untyped]
1010from geopy .geocoders import Nominatim # type: ignore[import-untyped]
11- from redis .exceptions import RedisError
11+ from redis .exceptions import ConnectionError , RedisError
1212
1313from .logging import get_logger
1414from .metrics import location_cache_operations , location_resolution_duration , track_time
@@ -48,9 +48,14 @@ def resolve_location(
4848 pass
4949
5050 # Check if in redis cache
51- cache : Optional [bytes ] = (
52- redis_client .get (data ) if redis_client is not None else None # type: ignore[assignment]
53- )
51+ try :
52+ cache : Optional [bytes ] = (
53+ redis_client .get (data ) if redis_client is not None else None # type: ignore[assignment]
54+ )
55+ except (ConnectionError , RedisError ) as err :
56+ logger .error ("Redis connection error" , err )
57+ return None , None , "Internal error" , False
58+
5459 if cache :
5560 lat_str , lon_str , address = cache .decode ("utf-8" ).split ("|" , 2 )
5661 location_cache_operations .labels (operation = "hit" ).inc ()
You can’t perform that action at this time.
0 commit comments