From 6f38dd482e3abb3171528943588b6536cdefee6f Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Tue, 25 Nov 2025 09:23:29 +0100 Subject: [PATCH] chore: only import catalogue if needed --- api_service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api_service.py b/api_service.py index c074c57..ceca917 100644 --- a/api_service.py +++ b/api_service.py @@ -5,7 +5,7 @@ This can run independently to support the PHP application import os import re -from bibapi import catalogue +# Avoid importing heavy modules at top-level to keep `import api_service` lightweight from fastapi import FastAPI, Query from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse @@ -28,7 +28,9 @@ cat = None def _get_catalogue(): global cat if cat is None: - cat = catalogue.Catalogue() + # import inside function to avoid expensive work during module import + from bibapi import catalogue as _catalogue + cat = _catalogue.Catalogue() return cat