sycommon-python-lib 0.1.50__py3-none-any.whl → 0.1.52__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.
@@ -53,7 +53,7 @@ class RabbitMQClient:
53
53
  self.exchange_type = ExchangeType(exchange_type.lower())
54
54
  except ValueError:
55
55
  logger.warning(f"无效的exchange_type: {exchange_type},默认使用'topic'")
56
- self.exchange_type = ExchangeType.TOPIC.name.lower()
56
+ self.exchange_type = ExchangeType.TOPIC
57
57
 
58
58
  # 队列配置
59
59
  self.queue_name = queue_name.strip() if queue_name else None
@@ -176,10 +176,6 @@ class RabbitMQClient:
176
176
  self._channel_conn.close_callbacks.add(
177
177
  self._conn_close_callback)
178
178
 
179
- # 单通道池已设置prefetch_count,无需重复设置
180
- logger.debug(f"使用连接池预配置的prefetch_count")
181
-
182
- # 默认启用异步发布确认
183
179
  # 重建交换机/队列资源
184
180
  await self._rebuild_resources()
185
181
 
@@ -311,16 +307,31 @@ class RabbitMQClient:
311
307
  return self._consumer_tag
312
308
 
313
309
  async def stop_consuming(self) -> None:
314
- """停止消息消费"""
310
+ """停止消息消费(适配 RobustChannel)"""
315
311
  async with self._consume_lock:
316
312
  try:
317
- if self._consumer_tag and self._queue and not self._queue.is_closed:
313
+ # 校验核心条件:消费标签、队列、通道均有效
314
+ if self._consumer_tag and self._queue and self._channel and not self._channel.is_closed:
315
+ # 使用队列的 cancel 方法(适配 RobustChannel)
318
316
  await self._queue.cancel(self._consumer_tag)
319
- logger.info(f"停止消费成功,consumer_tag: {self._consumer_tag}")
317
+ logger.info(
318
+ f"停止消费成功,consumer_tag: {self._consumer_tag},队列: {self._queue.name}"
319
+ )
320
+ elif self._consumer_tag:
321
+ # 部分资源无效时的日志提示
322
+ if not self._queue:
323
+ logger.warning(
324
+ f"消费标签存在但队列为空,无法取消消费(consumer_tag: {self._consumer_tag})")
325
+ elif not self._channel or self._channel.is_closed:
326
+ logger.warning(
327
+ f"通道已关闭,消费已自动停止(consumer_tag: {self._consumer_tag},队列: {self._queue.name if self._queue else '未知'})"
328
+ )
320
329
  except Exception as e:
321
- logger.error(f"停止消费失败: {str(e)}", exc_info=True)
330
+ logger.error(
331
+ f"停止消费者 '{self._queue.name if self._queue else '未知队列'}' 时出错: {str(e)}", exc_info=True
332
+ )
322
333
  finally:
323
- self._consumer_tag = None
334
+ self._consumer_tag = None # 无论成败,清理消费标签
324
335
 
325
336
  async def publish(
326
337
  self,
sycommon/services.py CHANGED
@@ -70,7 +70,7 @@ class Services(metaclass=SingletonMeta):
70
70
  app.state.config = {
71
71
  "host": cls._config.get('Host', '0.0.0.0'),
72
72
  "port": cls._config.get('Port', 8080),
73
- "workers": cls._config.get('Workers', 2),
73
+ "workers": cls._config.get('Workers', 1),
74
74
  "h11_max_incomplete_event_size": cls._config.get('H11MaxIncompleteEventSize', 1024 * 1024 * 10)
75
75
  }
76
76
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.1.50
3
+ Version: 0.1.52
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  command/cli.py,sha256=bP2LCLkRvfETIwWkVD70q5xFxMI4D3BpH09Ws1f-ENc,5849
2
2
  sycommon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- sycommon/services.py,sha256=6FfvwSbwfS0VydrZqK_tmC2HDS1qjIcvIocjc8fmCzU,11121
3
+ sycommon/services.py,sha256=SFMXZpVh4nGTocpdhu77qBWyFhLc-m95IV8CC4mh2ec,11121
4
4
  sycommon/config/Config.py,sha256=9yO5b8WfvEDvkyrGrlwrLFasgh_-MjcEvGF20Gz5Xo4,3041
5
5
  sycommon/config/DatabaseConfig.py,sha256=ILiUuYT9_xJZE2W-RYuC3JCt_YLKc1sbH13-MHIOPhg,804
6
6
  sycommon/config/EmbeddingConfig.py,sha256=gPKwiDYbeu1GpdIZXMmgqM7JqBIzCXi0yYuGRLZooMI,362
@@ -35,7 +35,7 @@ sycommon/models/mqlistener_config.py,sha256=vXp2uMmd0XQ5B9noSRXWHewTy-juQ2y7IsWt
35
35
  sycommon/models/mqmsg_model.py,sha256=cxn0M5b0utQK6crMYmL-1waeGYHvK3AlGaRy23clqTE,277
36
36
  sycommon/models/mqsend_config.py,sha256=NQX9dc8PpuquMG36GCVhJe8omAW1KVXXqr6lSRU6D7I,268
37
37
  sycommon/models/sso_user.py,sha256=i1WAN6k5sPcPApQEdtjpWDy7VrzWLpOrOQewGLGoGIw,2702
38
- sycommon/rabbitmq/rabbitmq_client.py,sha256=0lelVl9ILwrDw-xw9O1zSZfGJi40XQ_2eqrmriRlPRU,19410
38
+ sycommon/rabbitmq/rabbitmq_client.py,sha256=GkuYILMZJnvgZs4ID46I-w_UGzzI28YUydKgkTIDhIs,20226
39
39
  sycommon/rabbitmq/rabbitmq_pool.py,sha256=QtUcK4HuepRqRmy5XkUQo8gDgj74fr77CX7T5rN0y4I,15640
40
40
  sycommon/rabbitmq/rabbitmq_service.py,sha256=wpEJynP0gzbnmMyB02sfR9nTWB4hfTTP00xQxDJu644,38119
41
41
  sycommon/sse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -52,8 +52,8 @@ sycommon/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  sycommon/tools/docs.py,sha256=OPj2ETheuWjXLyaXtaZPbwmJKfJaYXV5s4XMVAUNrms,1607
53
53
  sycommon/tools/snowflake.py,sha256=DdEj3T5r5OEvikp3puxqmmmz6BrggxomoSlnsRFb5dM,1174
54
54
  sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
55
- sycommon_python_lib-0.1.50.dist-info/METADATA,sha256=Au96zy-nuoNUTrQeV2vgY267eyDVeSm4WP8j0I858zw,7037
56
- sycommon_python_lib-0.1.50.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
57
- sycommon_python_lib-0.1.50.dist-info/entry_points.txt,sha256=q_h2nbvhhmdnsOUZEIwpuoDjaNfBF9XqppDEmQn9d_A,46
58
- sycommon_python_lib-0.1.50.dist-info/top_level.txt,sha256=98CJ-cyM2WIKxLz-Pf0AitWLhJyrfXvyY8slwjTXNuc,17
59
- sycommon_python_lib-0.1.50.dist-info/RECORD,,
55
+ sycommon_python_lib-0.1.52.dist-info/METADATA,sha256=1ucpOddKw2gFQLUJPp2k_kJZ6M03xqVtvLbPSdnVcGQ,7037
56
+ sycommon_python_lib-0.1.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
57
+ sycommon_python_lib-0.1.52.dist-info/entry_points.txt,sha256=q_h2nbvhhmdnsOUZEIwpuoDjaNfBF9XqppDEmQn9d_A,46
58
+ sycommon_python_lib-0.1.52.dist-info/top_level.txt,sha256=98CJ-cyM2WIKxLz-Pf0AitWLhJyrfXvyY8slwjTXNuc,17
59
+ sycommon_python_lib-0.1.52.dist-info/RECORD,,