Merge pull request #106 from liz-in-tech/fix-cleanup-warning

fix: replace __del__ with atexit to fix RAGAnything cleanup warning
This commit is contained in:
zrguo
2025-09-16 15:40:18 +08:00
committed by GitHub
3 changed files with 7 additions and 3 deletions

View File

@@ -276,7 +276,7 @@ pip install -e '.[all]'
mineru --version
# Check if properly configured
python -c "from raganything import RAGAnything; rag = RAGAnything(); print('✅ MinerU installed properly' if rag.check_mineru_installation() else '❌ MinerU installation issue')"
python -c "from raganything import RAGAnything; rag = RAGAnything(); print('✅ MinerU installed properly' if rag.check_parser_installation() else '❌ MinerU installation issue')"
```
Models are downloaded automatically on first use. For manual download, refer to [MinerU Model Source Configuration](https://github.com/opendatalab/MinerU/blob/master/README.md#22-model-source-configuration).

View File

@@ -272,7 +272,7 @@ pip install -e '.[all]'
mineru --version
# 检查是否正确配置
python -c "from raganything import RAGAnything; rag = RAGAnything(); print('✅ MinerU安装正常' if rag.check_mineru_installation() else '❌ MinerU安装有问题')"
python -c "from raganything import RAGAnything; rag = RAGAnything(); print('✅ MinerU安装正常' if rag.check_parser_installation() else '❌ MinerU安装有问题')"
```
模型在首次使用时自动下载。手动下载参考[MinerU模型源配置](https://github.com/opendatalab/MinerU/blob/master/README_zh-CN.md#22-%E6%A8%A1%E5%9E%8B%E6%BA%90%E9%85%8D%E7%BD%AE)

View File

@@ -11,6 +11,7 @@ import os
from typing import Dict, Any, Optional, Callable
import sys
import asyncio
import atexit
from dataclasses import dataclass, field
from pathlib import Path
@@ -111,6 +112,9 @@ class RAGAnything(QueryMixin, ProcessorMixin, BatchMixin):
DoclingParser() if self.config.parser == "docling" else MineruParser()
)
# Register close method for cleanup
atexit.register(self.close)
# Create working directory if needed
if not os.path.exists(self.working_dir):
os.makedirs(self.working_dir)
@@ -128,7 +132,7 @@ class RAGAnything(QueryMixin, ProcessorMixin, BatchMixin):
)
self.logger.info(f" Max concurrent files: {self.config.max_concurrent_files}")
def __del__(self):
def close(self):
"""Cleanup resources when object is destroyed"""
try:
import asyncio