@@ -53,20 +53,28 @@ def __init__(self, yate, settings):
5353 self ._redis_pool = yate .redis_pool
5454
5555 async def retrieve (self , target ) -> Optional [IntermediateRoutingResult ]:
56- async with redis .Redis (
57- connection_pool = self ._redis_pool , decode_responses = True
58- ) as client :
59- data = await client .get (target )
56+ async with redis .Redis (connection_pool = self ._redis_pool ) as client :
57+ try :
58+ data = await client .get (target )
59+ except Exception as e :
60+ logging .error (
61+ "Failure to retrieve cached routing result from redis: %s" , e
62+ )
63+ raise
6064 if data is None :
6165 return None
6266 data = json .loads (data )
6367 return IntermediateRoutingResult .deserialize (data )
6468
6569 async def update (self , results : Dict [str , IntermediateRoutingResult ]):
66- async with redis .Redis (
67- connection_pool = self ._redis_pool , decode_responses = True
68- ) as client :
69- for key , routing_result in results .items ():
70- await client .setex (
71- key , self ._object_lifetime , json .dumps (routing_result .serialize ())
72- )
70+ async with redis .Redis (connection_pool = self ._redis_pool ) as client :
71+ try :
72+ for key , routing_result in results .items ():
73+ await client .setex (
74+ key ,
75+ self ._object_lifetime ,
76+ json .dumps (routing_result .serialize ()),
77+ )
78+ except Exception as e :
79+ logging .error ("Failure to update cached routing in redis: %s" , e )
80+ raise
0 commit comments