当前位置: 首页>>代码示例>>Python>>正文


Python AMQPClient.basic_get方法代码示例

本文整理汇总了Python中synnefo.lib.amqp.AMQPClient.basic_get方法的典型用法代码示例。如果您正苦于以下问题:Python AMQPClient.basic_get方法的具体用法?Python AMQPClient.basic_get怎么用?Python AMQPClient.basic_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在synnefo.lib.amqp.AMQPClient的用法示例。


在下文中一共展示了AMQPClient.basic_get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from synnefo.lib.amqp import AMQPClient [as 别名]
# 或者: from synnefo.lib.amqp.AMQPClient import basic_get [as 别名]
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a queue")

        queue = args[0]
        interactive = options['interactive']
        requeue = options['requeue']

        client = AMQPClient()
        client.connect()

        pp = pprint.PrettyPrinter(indent=4, width=4)

        more_msgs = True
        counter = 0
        sep = '-' * 80
        while more_msgs:
            msg = client.basic_get(queue=queue)
            if msg:
                counter += 1
                print sep
                print 'Message %d:' % counter
                print sep
                pp.pprint(msg)
                if not requeue or interactive:
                    if interactive and not get_user_confirmation():
                        continue
                    # Acknowledging the message will remove it from the queue
                    client.basic_ack(msg)
            else:
                more_msgs = False
开发者ID:antonis-m,项目名称:synnefo,代码行数:33,代码来源:queue-inspect.py

示例2: handle

# 需要导入模块: from synnefo.lib.amqp import AMQPClient [as 别名]
# 或者: from synnefo.lib.amqp.AMQPClient import basic_get [as 别名]
    def handle(self, *args, **options):
        verbose = (options["verbosity"] == "2")
        self.keep_zombies = options["keep_zombies"]
        log_level = logging.DEBUG if verbose else logging.WARNING
        log.setLevel(log_level)

        client = AMQPClient(confirms=False)
        client.connect()

        self.client = client

        for queue in queues.QUEUES:
            dead_queue = queues.convert_queue_to_dead(queue)
            while 1:
                message = client.basic_get(dead_queue)
                if not message:
                    break
                log.debug("Received message %s", message)
                self.handle_message(message)
        client.close()
        return 0
开发者ID:AthinaB,项目名称:synnefo,代码行数:23,代码来源:queue-retry.py


注:本文中的synnefo.lib.amqp.AMQPClient.basic_get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。