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


Python ChannelPool._free_channels方法代码示例

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


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

示例1: test_get_channel_when_two_free_and_one_closed

# 需要导入模块: from haigha.channel_pool import ChannelPool [as 别名]
# 或者: from haigha.channel_pool.ChannelPool import _free_channels [as 别名]
    def test_get_channel_when_two_free_and_one_closed(self):
        # Because we can't mock builtins ....
        class Set(set):

            def pop(self):
                pass

        conn = mock()
        ch1 = mock()
        ch1.closed = True
        ch2 = mock()
        ch2.closed = False
        cp = ChannelPool(conn)
        cp._free_channels = Set([ch1, ch2])
        cp._channels = 2

        # Because we want them in order
        expect(cp._free_channels.pop).returns(
            ch1).side_effect(super(Set, cp._free_channels).pop)
        expect(cp._free_channels.pop).returns(
            ch2).side_effect(super(Set, cp._free_channels).pop)

        self.assertEquals(ch2, cp._get_channel())
        self.assertEquals(set(), cp._free_channels)
        assert_equals(2, cp._channels)
开发者ID:3ddi,项目名称:haigha,代码行数:27,代码来源:channel_pool_test.py

示例2: test_get_channel_when_one_free_and_not_closed

# 需要导入模块: from haigha.channel_pool import ChannelPool [as 别名]
# 或者: from haigha.channel_pool.ChannelPool import _free_channels [as 别名]
    def test_get_channel_when_one_free_and_not_closed(self):
        conn = mock()
        ch = mock()
        ch.closed = False
        cp = ChannelPool(conn)
        cp._free_channels = set([ch])

        self.assertEquals(ch, cp._get_channel())
        self.assertEquals(set(), cp._free_channels)
开发者ID:3ddi,项目名称:haigha,代码行数:11,代码来源:channel_pool_test.py

示例3: test_get_channel_when_two_free_and_all_closed

# 需要导入模块: from haigha.channel_pool import ChannelPool [as 别名]
# 或者: from haigha.channel_pool.ChannelPool import _free_channels [as 别名]
  def test_get_channel_when_two_free_and_all_closed(self):
    conn = mock()
    ch1 = mock()
    ch1.closed = True
    ch2 = mock()
    ch2.closed = True
    cp = ChannelPool(conn)
    cp._free_channels = set([ch1,ch2])

    expect(conn.channel).returns('channel')

    self.assertEquals( 'channel', cp._get_channel() )
    self.assertEquals( set(), cp._free_channels )
开发者ID:ask,项目名称:haigha,代码行数:15,代码来源:channel_pool_test.py

示例4: test_get_channel_when_two_free_and_all_closed

# 需要导入模块: from haigha.channel_pool import ChannelPool [as 别名]
# 或者: from haigha.channel_pool.ChannelPool import _free_channels [as 别名]
    def test_get_channel_when_two_free_and_all_closed(self):
        conn = mock()
        ch1 = mock()
        ch1.closed = True
        ch2 = mock()
        ch2.closed = True
        cp = ChannelPool(conn)
        cp._free_channels = set([ch1, ch2])
        cp._channels = 2

        with expect(conn.channel).returns(mock()) as newchannel:
            expect(newchannel.add_close_listener).args(cp._channel_closed_cb)
            self.assertEquals(newchannel, cp._get_channel())

        self.assertEquals(set(), cp._free_channels)
        assert_equals(3, cp._channels)
开发者ID:3ddi,项目名称:haigha,代码行数:18,代码来源:channel_pool_test.py


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