RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: possible memory leaks close #5277 (#5500)
yihong8a2542157fc2
diff --git a/api/utils/file_utils.py b/api/utils/file_utils.pyindex ed014ac0e5..d76be81c97 100644--- a/api/utils/file_utils.py+++ b/api/utils/file_utils.py@@ -188,6 +188,7 @@ def thumbnail_img(filename, blob):buffered = BytesIO()else:break+ pdf.close()return imgelif re.match(r".*\.(jpg|jpeg|png|tif|gif|icon|ico|webp)$", filename):diff --git a/deepdoc/parser/pdf_parser.py b/deepdoc/parser/pdf_parser.pyindex 2282a87fb3..d4645f8a95 100644--- a/deepdoc/parser/pdf_parser.py+++ b/deepdoc/parser/pdf_parser.py@@ -950,7 +950,9 @@ class RAGFlowPdfParser:try:pdf = pdfplumber.open(fnm) if not binary else pdfplumber.open(BytesIO(binary))- return len(pdf.pages)+ total_page = len(pdf.pages)+ pdf.close()+ return total_pageexcept Exception:logging.exception("total_page_number")@@ -996,8 +998,11 @@ class RAGFlowPdfParser:dfs(outlines, 0)except Exception as e:logging.warning(f"Outlines exception: {e}")+ finally:+ self.pdf.close()if not self.outlines:logging.warning("Miss outlines")+logging.debug("Images converted.")self.is_english = [re.search(r"[a-zA-Z0-9,/¸;:'\[\]\(\)!@#$%^&*\"?<>._-]{30,}", "".join(diff --git a/deepdoc/vision/__init__.py b/deepdoc/vision/__init__.pyindex 64afcaf723..c67178c8fe 100644--- a/deepdoc/vision/__init__.py+++ b/deepdoc/vision/__init__.py@@ -42,6 +42,7 @@ def init_in_out(args):for i, page in enumerate(images):outputs.append(os.path.split(fnm)[-1] + f"_{i}.jpg")+ pdf.close()def images_and_outputs(fnm):nonlocal outputs, imagesdiff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.pyindex 3fc69f3f5e..05388f8dff 100644--- a/rag/svr/task_executor.py+++ b/rag/svr/task_executor.py@@ -18,6 +18,7 @@# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all codeimport randomimport sys+from api.utils.log_utils import initRootLogger, get_project_base_directoryfrom graphrag.general.index import WithCommunity, WithResolution, Dealerfrom graphrag.light.graph_extractor import GraphExtractor as LightKGExt