fix(edge): 配置推送后异步启动摄像头,不阻塞HTTP响应

问题:配置推送时同步启动摄像头,需等待13秒才返回响应,
导致云端10秒超时认为推送失败

修复:将_reload_cameras()改为异步执行:
1. 配置更新写入SQLite
2. 立即返回HTTP 200响应(<1秒)
3. 后台线程异步启动摄像头(10-15秒)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 22:36:56 +08:00
parent a38d599544
commit 7b3265fe74

View File

@@ -100,8 +100,13 @@ class EdgeInferenceService:
self._algorithm_manager.reload_all_algorithms()
# 配置更新后清理无ROI的摄像头流
self._cleanup_cameras_without_roi()
# 配置更新后动态加载新摄像头流(有ROI的
self._reload_cameras()
# 配置更新后动态加载新摄像头流(异步执行不阻塞HTTP响应
import threading
threading.Thread(
target=self._reload_cameras,
name="CameraReloader",
daemon=True
).start()
self._config_manager.register_callback("config_update", _on_config_update)
self._logger.info("配置管理器初始化成功")
except Exception as e: