async parallel node dependency installation with after_install hook
This commit is contained in:
parent
deb2b3295c
commit
91818f1786
@ -148,13 +148,12 @@ def _format_install_result(node_type: str, success: bool, stdout: str, stderr: s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def install_node_dependencies(node_type: str, sync: bool = True) -> Dict[str, Any]:
|
def install_node_dependencies(node_type: str) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
安装节点的依赖
|
安装节点的依赖(同步版本,用于单个节点安装)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
node_type: 节点类型
|
node_type: 节点类型
|
||||||
sync: 是否同步安装(当前未使用,保留以兼容未来扩展)
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
安装结果字典
|
安装结果字典
|
||||||
@ -576,31 +575,25 @@ def install_all_nodes_dependencies(max_concurrent: int = 5) -> List[Dict[str, An
|
|||||||
return await asyncio.gather(*tasks, return_exceptions=True)
|
return await asyncio.gather(*tasks, return_exceptions=True)
|
||||||
|
|
||||||
# 运行异步函数
|
# 运行异步函数
|
||||||
try:
|
results = asyncio.run(install_all())
|
||||||
results = asyncio.run(install_all())
|
|
||||||
|
# 处理异常结果
|
||||||
# 处理异常结果
|
processed_results = []
|
||||||
processed_results = []
|
for i, result in enumerate(results):
|
||||||
for i, result in enumerate(results):
|
if isinstance(result, Exception):
|
||||||
if isinstance(result, Exception):
|
node_type = nodes[i]
|
||||||
node_type = nodes[i]
|
logger.error(f"安装节点 {node_type} 依赖时发生异常: {str(result)}")
|
||||||
logger.error(f"安装节点 {node_type} 依赖时发生异常: {str(result)}")
|
processed_results.append({
|
||||||
processed_results.append({
|
"success": False,
|
||||||
"success": False,
|
"error": f"异常: {str(result)}",
|
||||||
"error": f"异常: {str(result)}",
|
"node_type": node_type
|
||||||
"node_type": node_type
|
})
|
||||||
})
|
else:
|
||||||
else:
|
processed_results.append(result)
|
||||||
processed_results.append(result)
|
|
||||||
|
# 统计结果
|
||||||
# 统计结果
|
success_count = sum(1 for r in processed_results if r.get("success"))
|
||||||
success_count = sum(1 for r in processed_results if r.get("success"))
|
logger.info(f"节点依赖安装完成: {success_count}/{len(nodes)} 成功")
|
||||||
logger.info(f"节点依赖安装完成: {success_count}/{len(nodes)} 成功")
|
|
||||||
|
return processed_results
|
||||||
return processed_results
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"并行安装节点依赖时发生异常: {str(e)}")
|
|
||||||
# 如果异步安装失败,回退到同步安装
|
|
||||||
logger.warning("回退到同步安装模式")
|
|
||||||
return [install_node_dependencies(node) for node in nodes]
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user