crawlo 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of crawlo might be problematic. Click here for more details.

Files changed (41) hide show
  1. crawlo/__version__.py +1 -1
  2. crawlo/core/scheduler.py +20 -16
  3. crawlo/downloader/httpx_downloader.py +14 -12
  4. crawlo/exceptions.py +4 -0
  5. crawlo/extension/__init__.py +17 -10
  6. crawlo/extension/health_check.py +142 -0
  7. crawlo/extension/log_interval.py +27 -18
  8. crawlo/extension/log_stats.py +62 -24
  9. crawlo/extension/logging_extension.py +18 -9
  10. crawlo/extension/memory_monitor.py +89 -0
  11. crawlo/extension/performance_profiler.py +118 -0
  12. crawlo/extension/request_recorder.py +108 -0
  13. crawlo/filters/aioredis_filter.py +2 -2
  14. crawlo/middleware/retry.py +3 -3
  15. crawlo/network/request.py +2 -2
  16. crawlo/network/response.py +25 -23
  17. crawlo/pipelines/__init__.py +9 -0
  18. crawlo/pipelines/bloom_dedup_pipeline.py +157 -0
  19. crawlo/pipelines/database_dedup_pipeline.py +225 -0
  20. crawlo/pipelines/memory_dedup_pipeline.py +116 -0
  21. crawlo/pipelines/mongo_pipeline.py +81 -66
  22. crawlo/pipelines/mysql_pipeline.py +165 -43
  23. crawlo/pipelines/redis_dedup_pipeline.py +163 -0
  24. crawlo/queue/queue_manager.py +4 -0
  25. crawlo/queue/redis_priority_queue.py +20 -3
  26. crawlo/settings/default_settings.py +119 -66
  27. crawlo/subscriber.py +62 -37
  28. crawlo/templates/project/items.py.tmpl +1 -1
  29. crawlo/templates/project/middlewares.py.tmpl +73 -49
  30. crawlo/templates/project/pipelines.py.tmpl +52 -290
  31. crawlo/templates/project/run.py.tmpl +20 -7
  32. crawlo/templates/project/settings.py.tmpl +35 -3
  33. crawlo/templates/spider/spider.py.tmpl +1 -37
  34. crawlo/utils/controlled_spider_mixin.py +109 -5
  35. crawlo-1.1.4.dist-info/METADATA +403 -0
  36. {crawlo-1.1.2.dist-info → crawlo-1.1.4.dist-info}/RECORD +40 -31
  37. examples/controlled_spider_example.py +205 -0
  38. crawlo-1.1.2.dist-info/METADATA +0 -567
  39. {crawlo-1.1.2.dist-info → crawlo-1.1.4.dist-info}/WHEEL +0 -0
  40. {crawlo-1.1.2.dist-info → crawlo-1.1.4.dist-info}/entry_points.txt +0 -0
  41. {crawlo-1.1.2.dist-info → crawlo-1.1.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,225 @@
1
+ #!/usr/bin/python
2
+ # -*- coding:UTF-8 -*-
3
+ """
4
+ 基于数据库的数据项去重管道
5
+ =======================
6
+ 提供持久化去重功能,适用于需要长期运行或断点续爬的场景。
7
+
8
+ 特点:
9
+ - 持久化存储: 重启爬虫后仍能保持去重状态
10
+ - 可靠性高: 数据库事务保证一致性
11
+ - 适用性广: 支持多种数据库后端
12
+ - 可扩展: 支持自定义表结构和字段
13
+ """
14
+
15
+ import hashlib
16
+ from typing import Dict, Any, Optional
17
+ import aiomysql
18
+
19
+ from crawlo import Item
20
+ from crawlo.spider import Spider
21
+ from crawlo.utils.log import get_logger
22
+ from crawlo.exceptions import DropItem
23
+
24
+
25
+ class DatabaseDedupPipeline:
26
+ """基于数据库的数据项去重管道"""
27
+
28
+ def __init__(
29
+ self,
30
+ db_host: str = 'localhost',
31
+ db_port: int = 3306,
32
+ db_user: str = 'root',
33
+ db_password: str = '',
34
+ db_name: str = 'crawlo',
35
+ table_name: str = 'item_fingerprints',
36
+ log_level: str = "INFO"
37
+ ):
38
+ """
39
+ 初始化数据库去重管道
40
+
41
+ :param db_host: 数据库主机地址
42
+ :param db_port: 数据库端口
43
+ :param db_user: 数据库用户名
44
+ :param db_password: 数据库密码
45
+ :param db_name: 数据库名称
46
+ :param table_name: 存储指纹的表名
47
+ :param log_level: 日志级别
48
+ """
49
+ self.logger = get_logger(self.__class__.__name__, log_level)
50
+
51
+ # 数据库连接参数
52
+ self.db_config = {
53
+ 'host': db_host,
54
+ 'port': db_port,
55
+ 'user': db_user,
56
+ 'password': db_password,
57
+ 'db': db_name,
58
+ 'autocommit': False
59
+ }
60
+
61
+ self.table_name = table_name
62
+ self.dropped_count = 0
63
+ self.connection = None
64
+ self.pool = None
65
+
66
+ @classmethod
67
+ def from_crawler(cls, crawler):
68
+ """从爬虫配置创建管道实例"""
69
+ settings = crawler.settings
70
+
71
+ return cls(
72
+ db_host=settings.get('DB_HOST', 'localhost'),
73
+ db_port=settings.getint('DB_PORT', 3306),
74
+ db_user=settings.get('DB_USER', 'root'),
75
+ db_password=settings.get('DB_PASSWORD', ''),
76
+ db_name=settings.get('DB_NAME', 'crawlo'),
77
+ table_name=settings.get('DB_DEDUP_TABLE', 'item_fingerprints'),
78
+ log_level=settings.get('LOG_LEVEL', 'INFO')
79
+ )
80
+
81
+ async def open_spider(self, spider: Spider) -> None:
82
+ """
83
+ 爬虫启动时初始化数据库连接
84
+
85
+ :param spider: 爬虫实例
86
+ """
87
+ try:
88
+ # 创建连接池
89
+ self.pool = await aiomysql.create_pool(
90
+ **self.db_config,
91
+ minsize=2,
92
+ maxsize=10
93
+ )
94
+
95
+ # 创建去重表(如果不存在)
96
+ await self._create_dedup_table()
97
+
98
+ self.logger.info(f"数据库去重管道初始化完成: {self.db_config['host']}:{self.db_config['port']}/{self.db_config['db']}.{self.table_name}")
99
+ except Exception as e:
100
+ self.logger.error(f"数据库去重管道初始化失败: {e}")
101
+ raise RuntimeError(f"数据库去重管道初始化失败: {e}")
102
+
103
+ async def _create_dedup_table(self) -> None:
104
+ """创建去重表"""
105
+ create_table_sql = f"""
106
+ CREATE TABLE IF NOT EXISTS `{self.table_name}` (
107
+ `id` BIGINT AUTO_INCREMENT PRIMARY KEY,
108
+ `fingerprint` VARCHAR(64) NOT NULL UNIQUE,
109
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
110
+ INDEX `idx_fingerprint` (`fingerprint`)
111
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
112
+ """
113
+
114
+ async with self.pool.acquire() as conn:
115
+ async with conn.cursor() as cursor:
116
+ await cursor.execute(create_table_sql)
117
+ await conn.commit()
118
+
119
+ async def process_item(self, item: Item, spider: Spider) -> Item:
120
+ """
121
+ 处理数据项,进行去重检查
122
+
123
+ :param item: 要处理的数据项
124
+ :param spider: 爬虫实例
125
+ :return: 处理后的数据项或抛出 DropItem 异常
126
+ """
127
+ try:
128
+ # 生成数据项指纹
129
+ fingerprint = self._generate_item_fingerprint(item)
130
+
131
+ # 检查指纹是否已存在
132
+ exists = await self._check_fingerprint_exists(fingerprint)
133
+
134
+ if exists:
135
+ # 如果已存在,丢弃这个数据项
136
+ self.dropped_count += 1
137
+ self.logger.debug(f"丢弃重复数据项: {fingerprint[:20]}...")
138
+ raise DropItem(f"重复的数据项: {fingerprint}")
139
+ else:
140
+ # 记录新数据项的指纹
141
+ await self._insert_fingerprint(fingerprint)
142
+ self.logger.debug(f"处理新数据项: {fingerprint[:20]}...")
143
+ return item
144
+
145
+ except Exception as e:
146
+ self.logger.error(f"处理数据项时出错: {e}")
147
+ # 在错误时继续处理,避免丢失数据
148
+ return item
149
+
150
+ async def _check_fingerprint_exists(self, fingerprint: str) -> bool:
151
+ """
152
+ 检查指纹是否已存在
153
+
154
+ :param fingerprint: 数据项指纹
155
+ :return: 是否存在
156
+ """
157
+ check_sql = f"SELECT 1 FROM `{self.table_name}` WHERE `fingerprint` = %s LIMIT 1"
158
+
159
+ async with self.pool.acquire() as conn:
160
+ async with conn.cursor() as cursor:
161
+ await cursor.execute(check_sql, (fingerprint,))
162
+ result = await cursor.fetchone()
163
+ return result is not None
164
+
165
+ async def _insert_fingerprint(self, fingerprint: str) -> None:
166
+ """
167
+ 插入新指纹
168
+
169
+ :param fingerprint: 数据项指纹
170
+ """
171
+ insert_sql = f"INSERT INTO `{self.table_name}` (`fingerprint`) VALUES (%s)"
172
+
173
+ async with self.pool.acquire() as conn:
174
+ async with conn.cursor() as cursor:
175
+ try:
176
+ await cursor.execute(insert_sql, (fingerprint,))
177
+ await conn.commit()
178
+ except aiomysql.IntegrityError:
179
+ # 指纹已存在(并发情况下可能发生)
180
+ await conn.rollback()
181
+ raise DropItem(f"重复的数据项: {fingerprint}")
182
+ except Exception:
183
+ await conn.rollback()
184
+ raise
185
+
186
+ def _generate_item_fingerprint(self, item: Item) -> str:
187
+ """
188
+ 生成数据项指纹
189
+
190
+ 基于数据项的所有字段生成唯一指纹,用于去重判断。
191
+
192
+ :param item: 数据项
193
+ :return: 指纹字符串
194
+ """
195
+ # 将数据项转换为可序列化的字典
196
+ try:
197
+ item_dict = item.to_dict()
198
+ except AttributeError:
199
+ # 兼容没有to_dict方法的Item实现
200
+ item_dict = dict(item)
201
+
202
+ # 对字典进行排序以确保一致性
203
+ sorted_items = sorted(item_dict.items())
204
+
205
+ # 生成指纹字符串
206
+ fingerprint_string = '|'.join([f"{k}={v}" for k, v in sorted_items if v is not None])
207
+
208
+ # 使用 SHA256 生成固定长度的指纹
209
+ return hashlib.sha256(fingerprint_string.encode('utf-8')).hexdigest()
210
+
211
+ async def close_spider(self, spider: Spider) -> None:
212
+ """
213
+ 爬虫关闭时的清理工作
214
+
215
+ :param spider: 爬虫实例
216
+ """
217
+ try:
218
+ if self.pool:
219
+ self.pool.close()
220
+ await self.pool.wait_closed()
221
+
222
+ self.logger.info(f"爬虫 {spider.name} 关闭:")
223
+ self.logger.info(f" - 丢弃的重复数据项: {self.dropped_count}")
224
+ except Exception as e:
225
+ self.logger.error(f"关闭爬虫时出错: {e}")
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/python
2
+ # -*- coding:UTF-8 -*-
3
+ """
4
+ 基于内存的数据项去重管道
5
+ ======================
6
+ 提供单节点环境下的数据项去重功能,防止保存重复的数据记录。
7
+
8
+ 特点:
9
+ - 高性能: 使用内存集合进行快速查找
10
+ - 简单易用: 无需外部依赖
11
+ - 轻量级: 适用于小规模数据采集
12
+ - 低延迟: 内存操作无网络开销
13
+ """
14
+
15
+ import hashlib
16
+ from typing import Dict, Any, Set
17
+
18
+ from crawlo import Item
19
+ from crawlo.spider import Spider
20
+ from crawlo.utils.log import get_logger
21
+ from crawlo.exceptions import DropItem
22
+
23
+
24
+ class MemoryDedupPipeline:
25
+ """基于内存的数据项去重管道"""
26
+
27
+ def __init__(self, log_level: str = "INFO"):
28
+ """
29
+ 初始化内存去重管道
30
+
31
+ :param log_level: 日志级别
32
+ """
33
+ self.logger = get_logger(self.__class__.__name__, log_level)
34
+
35
+ # 使用集合存储已见过的数据项指纹
36
+ self.seen_items: Set[str] = set()
37
+ self.dropped_count = 0
38
+
39
+ self.logger.info("内存去重管道初始化完成")
40
+
41
+ @classmethod
42
+ def from_crawler(cls, crawler):
43
+ """从爬虫配置创建管道实例"""
44
+ settings = crawler.settings
45
+
46
+ return cls(
47
+ log_level=settings.get('LOG_LEVEL', 'INFO')
48
+ )
49
+
50
+ def process_item(self, item: Item, spider: Spider) -> Item:
51
+ """
52
+ 处理数据项,进行去重检查
53
+
54
+ :param item: 要处理的数据项
55
+ :param spider: 爬虫实例
56
+ :return: 处理后的数据项或抛出 DropItem 异常
57
+ """
58
+ try:
59
+ # 生成数据项指纹
60
+ fingerprint = self._generate_item_fingerprint(item)
61
+
62
+ # 检查指纹是否已存在
63
+ if fingerprint in self.seen_items:
64
+ # 如果已存在,丢弃这个数据项
65
+ self.dropped_count += 1
66
+ self.logger.debug(f"丢弃重复数据项: {fingerprint[:20]}...")
67
+ raise DropItem(f"重复的数据项: {fingerprint}")
68
+ else:
69
+ # 记录新数据项的指纹
70
+ self.seen_items.add(fingerprint)
71
+ self.logger.debug(f"处理新数据项: {fingerprint[:20]}...")
72
+ return item
73
+
74
+ except Exception as e:
75
+ self.logger.error(f"处理数据项时出错: {e}")
76
+ # 在错误时继续处理,避免丢失数据
77
+ return item
78
+
79
+ def _generate_item_fingerprint(self, item: Item) -> str:
80
+ """
81
+ 生成数据项指纹
82
+
83
+ 基于数据项的所有字段生成唯一指纹,用于去重判断。
84
+
85
+ :param item: 数据项
86
+ :return: 指纹字符串
87
+ """
88
+ # 将数据项转换为可序列化的字典
89
+ try:
90
+ item_dict = item.to_dict()
91
+ except AttributeError:
92
+ # 兼容没有to_dict方法的Item实现
93
+ item_dict = dict(item)
94
+
95
+ # 对字典进行排序以确保一致性
96
+ sorted_items = sorted(item_dict.items())
97
+
98
+ # 生成指纹字符串
99
+ fingerprint_string = '|'.join([f"{k}={v}" for k, v in sorted_items if v is not None])
100
+
101
+ # 使用 SHA256 生成固定长度的指纹
102
+ return hashlib.sha256(fingerprint_string.encode('utf-8')).hexdigest()
103
+
104
+ def close_spider(self, spider: Spider) -> None:
105
+ """
106
+ 爬虫关闭时的清理工作
107
+
108
+ :param spider: 爬虫实例
109
+ """
110
+ self.logger.info(f"爬虫 {spider.name} 关闭:")
111
+ self.logger.info(f" - 丢弃的重复数据项: {self.dropped_count}")
112
+ self.logger.info(f" - 内存中存储的指纹数: {len(self.seen_items)}")
113
+
114
+ # 清理内存
115
+ self.seen_items.clear()
116
+ self.dropped_count = 0
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- from typing import Optional
2
+ from typing import Optional, List, Dict
3
3
  from motor.motor_asyncio import AsyncIOMotorClient
4
4
  from pymongo.errors import PyMongoError
5
5
  from crawlo.utils.log import get_logger
@@ -21,6 +21,17 @@ class MongoPipeline:
21
21
  self.mongo_uri = self.settings.get('MONGO_URI', 'mongodb://localhost:27017')
22
22
  self.db_name = self.settings.get('MONGO_DATABASE', 'scrapy_db')
23
23
  self.collection_name = self.settings.get('MONGO_COLLECTION', crawler.spider.name)
24
+
25
+ # 连接池配置
26
+ self.max_pool_size = self.settings.getint('MONGO_MAX_POOL_SIZE', 100)
27
+ self.min_pool_size = self.settings.getint('MONGO_MIN_POOL_SIZE', 10)
28
+ self.connect_timeout_ms = self.settings.getint('MONGO_CONNECT_TIMEOUT_MS', 5000)
29
+ self.socket_timeout_ms = self.settings.getint('MONGO_SOCKET_TIMEOUT_MS', 30000)
30
+
31
+ # 批量插入配置
32
+ self.batch_size = self.settings.getint('MONGO_BATCH_SIZE', 100)
33
+ self.use_batch = self.settings.getbool('MONGO_USE_BATCH', False)
34
+ self.batch_buffer: List[Dict] = [] # 批量缓冲区
24
35
 
25
36
  # 注册关闭事件
26
37
  crawler.subscriber.subscribe(self.spider_closed, event='spider_closed')
@@ -32,86 +43,90 @@ class MongoPipeline:
32
43
  async def _ensure_connection(self):
33
44
  """确保连接已建立"""
34
45
  if self.client is None:
35
- self.client = AsyncIOMotorClient(self.mongo_uri)
46
+ # 使用连接池配置创建客户端
47
+ self.client = AsyncIOMotorClient(
48
+ self.mongo_uri,
49
+ maxPoolSize=self.max_pool_size,
50
+ minPoolSize=self.min_pool_size,
51
+ connectTimeoutMS=self.connect_timeout_ms,
52
+ socketTimeoutMS=self.socket_timeout_ms
53
+ )
36
54
  self.db = self.client[self.db_name]
37
55
  self.collection = self.db[self.collection_name]
38
56
  self.logger.info(f"MongoDB连接建立 (集合: {self.collection_name})")
39
57
 
40
58
  async def process_item(self, item, spider) -> Optional[dict]:
41
- """处理item的核心方法"""
42
- try:
43
- await self._ensure_connection()
44
-
45
- item_dict = dict(item)
46
- result = await self.collection.insert_one(item_dict)
47
-
48
- # 统计计数
49
- self.crawler.stats.inc_value('mongodb/inserted')
50
- self.logger.debug(f"插入文档ID: {result.inserted_id}")
51
-
59
+ """处理item的核心方法(带重试机制)"""
60
+ # 如果启用批量插入,将item添加到缓冲区
61
+ if self.use_batch:
62
+ self.batch_buffer.append(dict(item))
63
+
64
+ # 如果缓冲区达到批量大小,执行批量插入
65
+ if len(self.batch_buffer) >= self.batch_size:
66
+ await self._flush_batch(spider)
67
+
52
68
  return item
69
+ else:
70
+ # 单条插入逻辑
71
+ try:
72
+ await self._ensure_connection()
73
+
74
+ item_dict = dict(item)
75
+
76
+ # 带重试的插入操作
77
+ for attempt in range(3):
78
+ try:
79
+ result = await self.collection.insert_one(item_dict)
80
+ # 统一使用insert_success统计键名
81
+ self.crawler.stats.inc_value('mongodb/insert_success')
82
+ self.logger.debug(f"插入成功 [attempt {attempt + 1}]: {result.inserted_id}")
83
+ return item
84
+ except PyMongoError as e:
85
+ if attempt == 2: # 最后一次尝试仍失败
86
+ raise
87
+ self.logger.warning(f"插入重试中 [attempt {attempt + 1}]: {e}")
88
+
89
+ except Exception as e:
90
+ # 统一使用insert_failed统计键名
91
+ self.crawler.stats.inc_value('mongodb/insert_failed')
92
+ self.logger.error(f"MongoDB操作最终失败: {e}")
93
+ raise ItemDiscard(f"MongoDB操作失败: {e}")
94
+
95
+ async def _flush_batch(self, spider):
96
+ """刷新批量缓冲区并执行批量插入"""
97
+ if not self.batch_buffer:
98
+ return
53
99
 
54
- except Exception as e:
55
- self.crawler.stats.inc_value('mongodb/failed')
56
- self.logger.error(f"MongoDB插入失败: {e}")
57
- raise ItemDiscard(f"MongoDB操作失败: {e}")
58
-
59
- async def spider_closed(self):
60
- """关闭爬虫时清理资源"""
61
- if self.client:
62
- self.client.close()
63
- self.logger.info("MongoDB连接已关闭")
64
-
65
-
66
- class MongoPoolPipeline:
67
- def __init__(self, crawler):
68
- self.crawler = crawler
69
- self.settings = crawler.settings
70
- self.logger = get_logger(self.__class__.__name__, self.settings.get('LOG_LEVEL'))
71
-
72
- # 连接池配置
73
- self.client = AsyncIOMotorClient(
74
- self.settings.get('MONGO_URI', 'mongodb://localhost:27017'),
75
- maxPoolSize=self.settings.getint('MONGO_MAX_POOL_SIZE', 100),
76
- minPoolSize=self.settings.getint('MONGO_MIN_POOL_SIZE', 10),
77
- connectTimeoutMS=5000,
78
- socketTimeoutMS=30000
79
- )
80
-
81
- self.db = self.client[self.settings.get('MONGO_DATABASE', 'scrapy_db')]
82
- self.collection = self.db[self.settings.get('MONGO_COLLECTION', crawler.spider.name)]
83
-
84
- crawler.subscriber.subscribe(self.spider_closed, event='spider_closed')
85
- self.logger.info(f"MongoDB连接池已初始化 (集合: {self.collection.name})")
86
-
87
- @classmethod
88
- def create_instance(cls, crawler):
89
- return cls(crawler)
90
-
91
- async def process_item(self, item, spider) -> Optional[dict]:
92
- """处理item方法(带重试机制)"""
93
100
  try:
94
- item_dict = dict(item)
101
+ await self._ensure_connection()
95
102
 
96
- # 带重试的插入操作
103
+ # 带重试的批量插入操作
97
104
  for attempt in range(3):
98
105
  try:
99
- result = await self.collection.insert_one(item_dict)
100
- self.crawler.stats.inc_value('mongodb/insert_success')
101
- self.logger.debug(f"插入成功 [attempt {attempt + 1}]: {result.inserted_id}")
102
- return item
106
+ result = await self.collection.insert_many(self.batch_buffer, ordered=False)
107
+ # 统一使用insert_success统计键名
108
+ inserted_count = len(result.inserted_ids)
109
+ self.crawler.stats.inc_value('mongodb/insert_success', inserted_count)
110
+ self.logger.debug(f"批量插入成功 [attempt {attempt + 1}]: {inserted_count} 条记录")
111
+ self.batch_buffer.clear()
112
+ return
103
113
  except PyMongoError as e:
104
114
  if attempt == 2: # 最后一次尝试仍失败
105
115
  raise
106
- self.logger.warning(f"插入重试中 [attempt {attempt + 1}]: {e}")
107
-
116
+ self.logger.warning(f"批量插入重试中 [attempt {attempt + 1}]: {e}")
108
117
  except Exception as e:
109
- self.crawler.stats.inc_value('mongodb/insert_failed')
110
- self.logger.error(f"MongoDB操作最终失败: {e}")
111
- raise ItemDiscard(f"MongoDB操作失败: {e}")
118
+ # 统一使用insert_failed统计键名
119
+ failed_count = len(self.batch_buffer)
120
+ self.crawler.stats.inc_value('mongodb/insert_failed', failed_count)
121
+ self.logger.error(f"MongoDB批量插入最终失败: {e}")
122
+ raise ItemDiscard(f"MongoDB批量插入失败: {e}")
112
123
 
113
124
  async def spider_closed(self):
114
- """资源清理"""
115
- if hasattr(self, 'client'):
125
+ """关闭爬虫时清理资源"""
126
+ # 在关闭前刷新剩余的批量数据
127
+ if self.use_batch and self.batch_buffer:
128
+ await self._flush_batch(self.crawler.spider)
129
+
130
+ if self.client:
116
131
  self.client.close()
117
- self.logger.info("MongoDB连接池已释放")
132
+ self.logger.info("MongoDB连接已关闭")