wip test stabalization is a mess still

This commit is contained in:
2026-03-03 23:53:53 -05:00
parent c0a8777204
commit 3203891b79
17 changed files with 263 additions and 422 deletions

View File

@@ -1280,16 +1280,29 @@ class App:
self._loop.run_forever()
def shutdown(self) -> None:
"""Cleanly shuts down the app's background tasks."""
"""Cleanly shuts down the app's background tasks and saves state."""
if hasattr(self, 'hook_server'):
self.hook_server.stop()
if hasattr(self, 'perf_monitor'):
self.perf_monitor.stop()
if self._loop.is_running():
self._loop.call_soon_threadsafe(self._loop.stop)
if self._loop_thread.is_alive():
self._loop_thread.join(timeout=2.0)
# Join other threads if they exist
# Join other threads if they exist
if self.send_thread and self.send_thread.is_alive():
self.send_thread.join(timeout=1.0)
if self.models_thread and self.models_thread.is_alive():
self.models_thread.join(timeout=1.0)
# Final State persistence
try:
ai_client.cleanup() # Destroy active API caches to stop billing
self._flush_to_project()
self._save_active_project()
self._flush_to_config()
save_config(self.config)
except: pass
async def _process_event_queue(self) -> None:
"""Listens for and processes events from the AsyncEventQueue."""
@@ -3611,19 +3624,10 @@ class App:
self.runner_params.callbacks.load_additional_fonts = self._load_fonts
self.runner_params.callbacks.post_init = self._post_init
self._fetch_models(self.current_provider)
# Start API hooks server (if enabled)
self.hook_server = api_hooks.HookServer(self)
self.hook_server.start()
immapp.run(self.runner_params)
# On exit
self.hook_server.stop()
self.perf_monitor.stop()
ai_client.cleanup() # Destroy active API caches to stop billing
self._flush_to_project()
self._save_active_project()
self._flush_to_config()
save_config(self.config)
session_logger.close_session()
self.shutdown()
session_logger.close_session()
def main() -> None:
app = App()