Jacek Zadrożny commited on
Commit
4ce8d8c
·
1 Parent(s): 478d8a6

Fix: Gradio app init for HF Spaces. Moved agent init and cleanup, removed demo.launch.

Browse files
Files changed (1) hide show
  1. app.py +10 -22
app.py CHANGED
@@ -154,25 +154,13 @@ with gr.Blocks(title="A11y Expert") as demo:
154
 
155
 
156
  # --- App Launch ---
157
- if __name__ == "__main__":
158
- # Register cleanup handler
159
- atexit.register(cleanup_resources)
160
-
161
- # Start agent initialization in background thread
162
- logger.info("🚀 Starting Gradio app with lazy agent initialization...")
163
- init_thread = threading.Thread(target=initialize_agent_background, daemon=True)
164
- init_thread.start()
165
-
166
- settings = get_settings()
167
- logger.info("Launching Gradio interface...")
168
-
169
- try:
170
- demo.launch(
171
- server_name=settings.server_host,
172
- server_port=settings.server_port,
173
- show_error=True,
174
- )
175
- except KeyboardInterrupt:
176
- logger.info("Received interrupt signal")
177
- finally:
178
- cleanup_resources()
 
154
 
155
 
156
  # --- App Launch ---
157
+ # Register cleanup handler
158
+ atexit.register(cleanup_resources)
159
+
160
+ # Start agent initialization in background thread
161
+ logger.info("🚀 Starting Gradio app with lazy agent initialization...")
162
+ init_thread = threading.Thread(target=initialize_agent_background, daemon=True)
163
+ init_thread.start()
164
+
165
+ # The demo.launch() call is intentionally omitted.
166
+ # Hugging Face Spaces automatically finds and launches the Gradio Blocks object.