Пример #1
0
    def test_clean(self):
        pool = ConnectionPool(max_host_count=2)

        conn1 = yield from pool.acquire('localhost', self.get_http_port())
        conn2 = yield from pool.acquire('localhost', self.get_http_port())

        yield from pool.release(conn1)
        yield from pool.release(conn2)
        yield from pool.clean()

        self.assertEqual(0, len(pool.host_pools))
Пример #2
0
    def test_connection_pool_release_clean_race_condition(self):
        pool = ConnectionPool(max_host_count=1)

        connection = yield from pool.acquire('127.0.0.1', 1234)
        connection_2_task = asyncio. async (pool.acquire('127.0.0.1', 1234))
        yield from asyncio.sleep(0.01)
        pool.no_wait_release(connection)
        yield from pool.clean(force=True)
        connection_2 = yield from connection_2_task

        # This line should not KeyError crash:
        yield from pool.release(connection_2)