ffzeroHua commited on
Commit
03828ea
·
verified ·
1 Parent(s): 7b50d9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -158,7 +158,7 @@ def background_eval_loop():
158
  sync_models_from_hub() # 🚀 启动时从 Riichi-Model-Repo 拉取对战模型
159
  sync_data_from_hub() # 🚀 启动时从战绩仓库拉取历史战绩
160
 
161
- NUM_WORKERS = 1
162
  print(f"🚀 节点 [{WORKER_ID}] 后台对战线程已启动: {TEST_MODEL} 挑战双 {EXAMINER_MODEL}")
163
 
164
  if not os.path.exists(REPORT_FILE):
@@ -284,7 +284,14 @@ with gr.Blocks() as demo:
284
 
285
  refresh_btn.click(fn=read_and_analyze, inputs=None, outputs=[stats_output, plot_output])
286
 
 
 
287
  if __name__ == "__main__":
 
 
 
 
 
288
  t = threading.Thread(target=background_eval_loop, daemon=True)
289
  t.start()
290
 
 
158
  sync_models_from_hub() # 🚀 启动时从 Riichi-Model-Repo 拉取对战模型
159
  sync_data_from_hub() # 🚀 启动时从战绩仓库拉取历史战绩
160
 
161
+ NUM_WORKERS = 2
162
  print(f"🚀 节点 [{WORKER_ID}] 后台对战线程已启动: {TEST_MODEL} 挑战双 {EXAMINER_MODEL}")
163
 
164
  if not os.path.exists(REPORT_FILE):
 
284
 
285
  refresh_btn.click(fn=read_and_analyze, inputs=None, outputs=[stats_output, plot_output])
286
 
287
+ import multiprocessing
288
+
289
  if __name__ == "__main__":
290
+ # 强制使用 spawn,解决 Rust FFI 多进程死锁问题
291
+ multiprocessing.set_start_method('spawn', force=True)
292
+
293
+ # 修复后,你可以安全地将 NUM_WORKERS 调大
294
+ # HF Space 免费层通常有 2 vCPU,可以设为 2。如果是更高配置的机器,设为 os.cpu_count() - 1
295
  t = threading.Thread(target=background_eval_loop, daemon=True)
296
  t.start()
297