diff --git a/backend/requirements.txt b/backend/requirements.txt index 9064092..2707c9c 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,3 +7,4 @@ mistralai==0.1.6 flask-socketio==5.3.6 python-socketio==5.11.0 simple-websocket==1.0.0 +eventlet==0.40.4 \ No newline at end of file diff --git a/backend/server.py b/backend/server.py index 1f603ec..3a29920 100644 --- a/backend/server.py +++ b/backend/server.py @@ -26,7 +26,7 @@ try: with open(yaml_file, "r", encoding="utf-8") as file: yaml_data = yaml.safe_load(file) except Exception: - yaml_file = {} + yaml_data = {} USE_CACHE: bool = os.getenv("USE_CACHE") if USE_CACHE is None: USE_CACHE = yaml_data.get("USE_CACHE", False) @@ -37,7 +37,8 @@ AgentProfile_Dict = {} Request_Cache: dict[str, str] = {} app = Flask(__name__) app.config['SECRET_KEY'] = 'agentcoord-secret-key' -socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading') +# socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading') +socketio = SocketIO(app, cors_allowed_origins="*", async_mode='eventlet') def truncate_rehearsal_log(RehearsalLog: List, restart_from_step_index: int) -> List: @@ -1767,4 +1768,5 @@ if __name__ == "__main__": args = parser.parse_args() init() # 使用 socketio.run 替代 app.run,支持WebSocket - socketio.run(app, host="0.0.0.0", port=args.port, debug=True, allow_unsafe_werkzeug=True) + # socketio.run(app, host="0.0.0.0", port=args.port, debug=True, allow_unsafe_werkzeug=True) + socketio.run(app, host="0.0.0.0", port=args.port, debug=False, allow_unsafe_werkzeug=True)