示例#1
0
    def test_multiple_hosts(self):
        pool = ConnectionPool(max_host_count=5, max_count=20)

        for port in range(10):
            session = yield From(pool.session('localhost', port))
            with session as connection:
                self.assertTrue(connection)
示例#2
0
    def test_multiple_hosts(self):
        pool = ConnectionPool(max_host_count=5, max_count=20)

        for port in range(10):
            session = yield From(
                pool.session('localhost', port)
            )
            with session as connection:
                self.assertTrue(connection)
示例#3
0
    def test_session(self):
        pool = ConnectionPool()

        for dummy in range(10):
            session = yield From(
                pool.session('localhost', self.get_http_port()))
            with session as connection:
                if connection.closed():
                    yield From(connection.connect())

        self.assertEqual(1, len(pool.host_pools))
        host_pool = list(pool.host_pools.values())[0]
        self.assertIsInstance(host_pool, HostPool)
        self.assertEqual(1, host_pool.count())
示例#4
0
    def test_session(self):
        pool = ConnectionPool()

        for dummy in range(10):
            session = yield From(
                pool.session('localhost', self.get_http_port())
            )
            with session as connection:
                if connection.closed():
                    yield From(connection.connect())

        self.assertEqual(1, len(pool.host_pools))
        host_pool = list(pool.host_pools.values())[0]
        self.assertIsInstance(host_pool, HostPool)
        self.assertEqual(1, host_pool.count())