Somuai12 commited on
Commit
9e34c41
·
1 Parent(s): 8eede32

Fix Gradio dashboard hang: restore module-level mounting (required for queue/WebSocket)

Browse files
Files changed (1) hide show
  1. server/app.py +7 -11
server/app.py CHANGED
@@ -378,17 +378,13 @@ def build_custom_ui():
378
 
379
  return demo
380
 
381
- # Lazy Gradio UI Mounting
382
- @app.on_event("startup")
383
- async def startup_event():
384
- import gradio as gr
385
- # Import locally to avoid module-level overhead
386
- try:
387
- custom_demo = build_custom_ui()
388
- gr.mount_gradio_app(app, custom_demo, path="/dashboard/")
389
- print("[INFO] PolicyEvolver Dashboard mounted at /dashboard/")
390
- except Exception as e:
391
- print(f"[WARNING] Failed to mount Gradio Dashboard: {e}")
392
 
393
  def main():
394
  # Sync with Hugging Face and local requirements
 
378
 
379
  return demo
380
 
381
+ # Mount Gradio at module level (required for Gradio queue/WebSocket to work)
382
+ try:
383
+ custom_demo = build_custom_ui()
384
+ app = gr.mount_gradio_app(app, custom_demo, path="/dashboard/")
385
+ print("[INFO] PolicyEvolver Dashboard mounted at /dashboard/")
386
+ except Exception as e:
387
+ print(f"[WARNING] Failed to mount Gradio Dashboard: {e}")
 
 
 
 
388
 
389
  def main():
390
  # Sync with Hugging Face and local requirements