sycommon-python-lib 0.1.51__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.
@@ -307,22 +307,29 @@ class RabbitMQClient:
307
307
  return self._consumer_tag
308
308
 
309
309
  async def stop_consuming(self) -> None:
310
- """停止消息消费(修复:移除 _queue.is_closed 判断)"""
310
+ """停止消息消费(适配 RobustChannel)"""
311
311
  async with self._consume_lock:
312
312
  try:
313
- # 判断 consumer_tag 和 queue 是否存在,通道状态通过 _channel 校验
313
+ # 校验核心条件:消费标签、队列、通道均有效
314
314
  if self._consumer_tag and self._queue and self._channel and not self._channel.is_closed:
315
- # 用通道取消消费(队列无cancel方法)
316
- await self._channel.basic_cancel(self._consumer_tag)
315
+ # 使用队列的 cancel 方法(适配 RobustChannel)
316
+ await self._queue.cancel(self._consumer_tag)
317
317
  logger.info(
318
- f"停止消费成功,consumer_tag: {self._consumer_tag},队列: {self._queue.name}")
319
- elif self._consumer_tag and self._queue:
320
- # 通道已关闭,无需执行cancel(消费已自动停止)
321
- logger.warning(
322
- f"通道已关闭,无需取消消费(consumer_tag: {self._consumer_tag})")
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
+ )
323
329
  except Exception as e:
324
330
  logger.error(
325
- f"停止消费者 '{self._queue.name if self._queue else '未知队列'}' 时出错: {str(e)}", exc_info=True)
331
+ f"停止消费者 '{self._queue.name if self._queue else '未知队列'}' 时出错: {str(e)}", exc_info=True
332
+ )
326
333
  finally:
327
334
  self._consumer_tag = None # 无论成败,清理消费标签
328
335
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.1.51
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
@@ -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=KUMNklTXK2cc66fNpThnZZpPLwfRH4-AwLQ2rsGEePk,19898
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.51.dist-info/METADATA,sha256=p5snEjLtK9zjIs4a4BySEavEY8FZn7Jw_XI4AtvLy2o,7037
56
- sycommon_python_lib-0.1.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
57
- sycommon_python_lib-0.1.51.dist-info/entry_points.txt,sha256=q_h2nbvhhmdnsOUZEIwpuoDjaNfBF9XqppDEmQn9d_A,46
58
- sycommon_python_lib-0.1.51.dist-info/top_level.txt,sha256=98CJ-cyM2WIKxLz-Pf0AitWLhJyrfXvyY8slwjTXNuc,17
59
- sycommon_python_lib-0.1.51.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,,