shut down download thread

This commit is contained in:
Lukas 2025-11-20 19:03:20 +01:00
parent 57da1f1272
commit 1ca105f330

View File

@ -101,6 +101,18 @@ async def lifespan(app: FastAPI):
# Shutdown
logger.info("FastAPI application shutting down")
# Shutdown download service and its thread pool
try:
from src.server.services.download_service import _download_service_instance
if _download_service_instance is not None:
logger.info("Stopping download service...")
await _download_service_instance.stop()
logger.info("Download service stopped successfully")
except Exception as e:
logger.error("Error stopping download service: %s", e, exc_info=True)
logger.info("FastAPI application shutdown complete")
# Initialize FastAPI app with lifespan
app = FastAPI(