From 39f0a0dc405d305fa144409747c91a76e2393ac5 Mon Sep 17 00:00:00 2001 From: Josh XT Date: Sat, 4 Jan 2025 22:02:30 -0500 Subject: [PATCH] kill tasks on shutdown --- agixt/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agixt/app.py b/agixt/app.py index 3b36be42bef5..54c3afcc6942 100644 --- a/agixt/app.py +++ b/agixt/app.py @@ -41,7 +41,7 @@ @asynccontextmanager async def lifespan(app: FastAPI): workspace_manager.start_file_watcher() - threading.Thread(target=task_monitor.start).start() + tasks = threading.Thread(target=task_monitor.start).start() NGROK_TOKEN = getenv("NGROK_TOKEN") if NGROK_TOKEN: from pyngrok import ngrok @@ -63,6 +63,8 @@ async def lifespan(app: FastAPI): # Shutdown workspace_manager.stop_file_watcher() task_monitor.stop() + if tasks: + tasks.kill() if NGROK_TOKEN: try: ngrok.kill()