【问题标题】:Documentation for result object from "queue_declare" in Pika来自 Pika 中“queue_declare”的结果对象的文档
【发布时间】:2012-12-11 05:35:26
【问题描述】:

在以下教程中:http://www.rabbitmq.com/tutorials/tutorial-three-python.html,有如下代码。

   result = channel.queue_declare(exclusive=True)
   queue_name = result.method.queue

Pika 的“结果”对象记录在哪里?我想知道我可以从中访问的所有内容。

【问题讨论】:

标签: python rabbitmq pika


【解决方案1】:

我忘记了昨晚显而易见的事情。 Python 通常是自我记录的,尤其是使用“dir”函数。在python内部运行这个,然后在结果对象上运行“result.__class__”,表明这是Pika中的一个METHOD对象。

>>> r
<METHOD(['frame_type=1', 'channel_number=1', 'method=<Exchange.DeclareOk>'])>
>>> r.__class__
<class 'pika.frame.Method'>
>>> dir(r)
['INDEX', 'NAME', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_marshal', 'channel_number', 'frame_type', 'marshal', 'method']

一些谷歌搜索将我带到这些文档:https://pika.readthedocs.org/en/latest/frame.html#method

不幸的是……

This class level documentation is not intended for use by those using Pika in their applications. This documentation is for those who are extending Pika or otherwise working on the driver itself.

因此,RabbitMQ 网站上的这个特定示例似乎使用了 Pika 的未记录功能。结果,我最终只是在我的应用程序中生成了我自己的唯一名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-20
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多