From c13e645916833fab283aad375cf13441368f7a86 Mon Sep 17 00:00:00 2001 From: ff137 Date: Wed, 27 Nov 2024 23:39:10 +0200 Subject: [PATCH] :sparkles: Add `lru_cache` to load_class and set maxsize Signed-off-by: ff137 --- acapy_agent/utils/classloader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acapy_agent/utils/classloader.py b/acapy_agent/utils/classloader.py index 8905c07b57..096da097d1 100644 --- a/acapy_agent/utils/classloader.py +++ b/acapy_agent/utils/classloader.py @@ -26,7 +26,7 @@ class ClassLoader: """Class used to load classes from modules dynamically.""" @classmethod - @lru_cache + @lru_cache(maxsize=1024) def load_module( cls, mod_path: str, package: Optional[str] = None ) -> Optional[ModuleType]: @@ -84,6 +84,7 @@ def load_module( raise ModuleLoadError(f"Unable to import module {full_path}: {str(e)}") from e @classmethod + @lru_cache(maxsize=1024) def load_class( cls, class_name: str,