diff --git a/run_script.py b/run_script.py index af4ab77..85e101b 100644 --- a/run_script.py +++ b/run_script.py @@ -130,7 +130,7 @@ async def run_script( result_lines = await shell_run_command( command=" ".join(cmd), return_all=True, - stream_level=10 # 使用 DEBUG 级别输出,实现实时输出效果 + stream_level=20 # 使用 INFO 级别输出,确保实时输出效果 ) # 将结果列表转换为字符串 @@ -244,6 +244,17 @@ def merge_params(*param_dicts: dict) -> dict: if __name__ == "__main__": import json + import asyncio + import logging + + # 配置日志,确保实时输出 + logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + handlers=[ + logging.StreamHandler() # 确保日志输出到控制台 + ] + ) # 1. 解析命令行参数 args = parse_command_line_args() @@ -284,11 +295,11 @@ if __name__ == "__main__": print(" python backtest.py --flow-config flow_config.json") exit(1) - # 7. 执行 Flow - result = start( + # 7. 执行 Flow(使用 asyncio.run() 正确调用异步函数) + result = asyncio.run(start( script_url=script_url, shell_script=shell_script - ) + )) print("完成!") print(f"命令: {result['command']}")