Browse Source

!2 sometimes restart and reset not work well

pcacc 4 days ago
parent
commit
416127ddfa
1 changed files with 4 additions and 2 deletions
  1. 4 2
      app_dongri.py

+ 4 - 2
app_dongri.py

@@ -230,7 +230,8 @@ def handle_restart_game():
 @app.route('/restart_game', methods=['POST'])
 def http_restart_game():
     print("HTTP 触发 restart_game")
-    socketio.start_background_task(handle_restart_game)
+    restartTask = threading.Thread(target=handle_restart_game, daemon=True)#启动线程往里面添加任务
+    restartTask.start()
     return jsonify({"status": "success", "message": "已重启"})
 
 @socketio.on('close_game')
@@ -243,7 +244,8 @@ def handle_close_game():
 def http_close_game():
     print("HTTP 触发 close_game")
     handle_close_game()
-    socketio.start_background_task(handle_reset_script)
+    resetTask = threading.Thread(target=handle_reset_script, daemon=True)#启动线程往里面添加任务
+    resetTask.start()
     return jsonify({"status": "success", "message": "已关闭"})