Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
fix: Catch Redis server errors
Clémence Lesné066cf4cfb314
diff --git a/persistence/redis.py b/persistence/redis.pyindex 385360f..a5a2455 100644--- a/persistence/redis.py+++ b/persistence/redis.py@@ -6,7 +6,7 @@ from persistence.icache import ICachefrom redis.asyncio import Redisfrom redis.asyncio.retry import Retryfrom redis.backoff import ExponentialBackoff-from redis.exceptions import BusyLoadingError, ConnectionError, TimeoutError+from redis.exceptions import BusyLoadingError, ConnectionError, TimeoutError, RedisErrorfrom typing import AsyncGenerator, Optional, Unionimport hashlib@@ -35,8 +35,11 @@ class RedisCache(ICache):"""sha_key = self._key_to_hash(key)res = None- async with self._use_db() as db:- res = await db.get(sha_key)+ try:+ async with self._use_db() as db:+ res = await db.get(sha_key)+ except RedisError as e:+ _logger.error(f"Error getting value, {e}")return resasync def aset(self, key: str, value: Union[str, bytes, None]) -> bool:@@ -48,8 +51,12 @@ class RedisCache(ICache):Catch errors for a maximum of 3 times, then raise the error."""sha_key = self._key_to_hash(key)- async with self._use_db() as db:- await db.set(sha_key, value if value else "")+ try:+ async with self._use_db() as db:+ await db.set(sha_key, value if value else "")+ except RedisError as e:+ _logger.error(f"Error setting value, {e}")+ return Falsereturn True@asynccontextmanager