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


Python Exchange.bind方法代码示例

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


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

示例1: test_assert_is_bound

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    def test_assert_is_bound(self):
        exchange = Exchange('foo', 'direct')
        with self.assertRaises(NotBoundError):
            exchange.declare()
        conn = get_conn()

        chan = conn.channel()
        exchange.bind(chan).declare()
        self.assertIn('exchange_declare', chan)
开发者ID:1995rishi,项目名称:flaskmap,代码行数:11,代码来源:test_entities.py

示例2: test_assert_is_bound

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    def test_assert_is_bound(self):
        exchange = Exchange('foo', 'direct')
        with pytest.raises(NotBoundError):
            exchange.declare()
        conn = get_conn()

        chan = conn.channel()
        exchange.bind(chan).declare()
        assert 'exchange_declare' in chan
开发者ID:celery,项目名称:kombu,代码行数:11,代码来源:test_entity.py

示例3: test_bound

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    def test_bound(self):
        exchange = Exchange('foo', 'direct')
        assert not exchange.is_bound
        assert '<unbound' in repr(exchange)

        chan = get_conn().channel()
        bound = exchange.bind(chan)
        assert bound.is_bound
        assert bound.channel is chan
        assert 'bound to chan:%r' % (chan.channel_id,) in repr(bound)
开发者ID:celery,项目名称:kombu,代码行数:12,代码来源:test_entity.py

示例4: test_bound

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    def test_bound(self):
        exchange = Exchange('foo', 'direct')
        self.assertFalse(exchange.is_bound)
        self.assertIn('<unbound', repr(exchange))

        chan = get_conn().channel()
        bound = exchange.bind(chan)
        self.assertTrue(bound.is_bound)
        self.assertIs(bound.channel, chan)
        self.assertIn('bound to chan:%r' % (chan.channel_id, ),
                      repr(bound))
开发者ID:1995rishi,项目名称:flaskmap,代码行数:13,代码来源:test_entities.py

示例5: test_revive

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    def test_revive(self):
        exchange = Exchange('foo', 'direct')
        conn = get_conn()
        chan = conn.channel()

        # reviving unbound channel is a noop.
        exchange.revive(chan)
        self.assertFalse(exchange.is_bound)
        self.assertIsNone(exchange._channel)

        bound = exchange.bind(chan)
        self.assertTrue(bound.is_bound)
        self.assertIs(bound.channel, chan)

        chan2 = conn.channel()
        bound.revive(chan2)
        self.assertTrue(bound.is_bound)
        self.assertIs(bound._channel, chan2)
开发者ID:1995rishi,项目名称:flaskmap,代码行数:20,代码来源:test_entities.py

示例6: test_revive

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    def test_revive(self):
        exchange = Exchange('foo', 'direct')
        conn = get_conn()
        chan = conn.channel()

        # reviving unbound channel is a noop.
        exchange.revive(chan)
        assert not exchange.is_bound
        assert exchange._channel is None

        bound = exchange.bind(chan)
        assert bound.is_bound
        assert bound.channel is chan

        chan2 = conn.channel()
        bound.revive(chan2)
        assert bound.is_bound
        assert bound._channel is chan2
开发者ID:celery,项目名称:kombu,代码行数:20,代码来源:test_entity.py

示例7: print

# 需要导入模块: from kombu import Exchange [as 别名]
# 或者: from kombu.Exchange import bind [as 别名]
    print('  properties:\n%s' % (pretty(message.properties), ))
    print('  delivery_info:\n%s' % (pretty(message.delivery_info), ))
    message.ack()

#: Create a connection and a channel.
#: If hostname, userid, password and virtual_host is not specified
#: the values below are the default, but listed here so it can
#: be easily changed.
with Connection('pyamqp://guest:[email protected]:5672//') as connection:
    
    """The configuration of the message flow is as follows:
    gateway_kombu_exchange -> internal_kombu_exchange -> kombu_demo queue 
    """
    gateway_exchange = Exchange('gateway_kombu_demo', type='direct')
    exchange = Exchange('internal_kombu_demo', type='direct')
    binded = exchange.bind(connection.channel())
    binded.exchange_bind(gateway_exchange, routing_key = 'kombu_demo')
    
    queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')
    
    #: Create consumer using our callback and queue.
    #: Second argument can also be a list to consume from
    #: any number of queues.
    with Consumer(connection, queue, callbacks=[handle_message]):

        #: This waits for a single event.  Note that this event may not
        #: be a message, or a message that is to be delivered to the consumers
        #: channel, but any event received on the connection.        
        recv = eventloop(connection)
        while True:
            recv.next()
开发者ID:rumineykova,项目名称:kombu,代码行数:33,代码来源:complete_receive.py


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