Spaces:
Running
Running
chore: update something
Browse files
lightweight_embeddings/analytics.py
CHANGED
|
@@ -239,8 +239,6 @@ class Analytics:
|
|
| 239 |
)
|
| 240 |
# Close existing connection
|
| 241 |
await loop.run_in_executor(None, self.redis_client.close)
|
| 242 |
-
if self.redis_client is not None:
|
| 243 |
-
await self.close()
|
| 244 |
# Create a new client
|
| 245 |
self.redis_client = self._create_redis_client()
|
| 246 |
# Test the new connection
|
|
@@ -258,20 +256,18 @@ class Analytics:
|
|
| 258 |
)
|
| 259 |
|
| 260 |
# Optional: Keep retrying indefinitely instead of giving up.
|
| 261 |
-
while True:
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
await asyncio.sleep(delay)
|
| 274 |
-
delay = min(delay * 2, 60) # Cap at 60 seconds or choose your own max
|
| 275 |
|
| 276 |
async def close(self):
|
| 277 |
"""
|
|
|
|
| 239 |
)
|
| 240 |
# Close existing connection
|
| 241 |
await loop.run_in_executor(None, self.redis_client.close)
|
|
|
|
|
|
|
| 242 |
# Create a new client
|
| 243 |
self.redis_client = self._create_redis_client()
|
| 244 |
# Test the new connection
|
|
|
|
| 256 |
)
|
| 257 |
|
| 258 |
# Optional: Keep retrying indefinitely instead of giving up.
|
| 259 |
+
# while True:
|
| 260 |
+
# try:
|
| 261 |
+
# logger.info("Retrying to reconnect to Redis...")
|
| 262 |
+
# await loop.run_in_executor(None, self.redis_client.close)
|
| 263 |
+
# self.redis_client = self._create_redis_client()
|
| 264 |
+
# await loop.run_in_executor(None, self.redis_client.ping)
|
| 265 |
+
# logger.info("Reconnected to Redis after extended retries.")
|
| 266 |
+
# break
|
| 267 |
+
# except redis.exceptions.ConnectionError as e:
|
| 268 |
+
# logger.error("Extended reconnection attempt failed: %s", e)
|
| 269 |
+
# await asyncio.sleep(delay)
|
| 270 |
+
# delay = min(delay * 2, 60) # Cap at 60 seconds or choose your own max
|
|
|
|
|
|
|
| 271 |
|
| 272 |
async def close(self):
|
| 273 |
"""
|