From d5c443c7c62027c0607f9ffab91b06839482a1cd Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Fri, 20 Mar 2026 10:03:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E4=BA=91=E7=AB=AF?= =?UTF-8?q?=20Redis=20=E8=BF=9E=E6=8E=A5=E5=8A=A0=20keepalive=20+=20?= =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=A3=80=E6=9F=A5=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E9=A2=91=E7=B9=81=E6=96=AD=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 腾讯云 Redis 空闲连接超时会主动断开,加 socket_keepalive=True 和 health_check_interval=30 保活,减少重连频率。 --- core/config_sync.py | 2 ++ main.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/config_sync.py b/core/config_sync.py index 1ae53e6..233c037 100644 --- a/core/config_sync.py +++ b/core/config_sync.py @@ -206,6 +206,8 @@ class ConfigSyncManager: socket_connect_timeout=10, socket_timeout=10, retry_on_timeout=True, + socket_keepalive=True, + health_check_interval=30, ) self._cloud_redis.ping() logger.info(f"云端 Redis 连接成功: {cfg.host}:{cfg.port}/{cfg.db}") diff --git a/main.py b/main.py index 975813d..ea63cb5 100644 --- a/main.py +++ b/main.py @@ -200,6 +200,8 @@ class EdgeInferenceService: socket_connect_timeout=5, socket_timeout=10, retry_on_timeout=True, + socket_keepalive=True, + health_check_interval=30, ) cloud_redis.ping() self._logger.info(f"截图处理器独立连接云端 Redis 成功: {cfg.host}:{cfg.port}/{cfg.db}")