Ejemplo n.º 1
0
    def setUp(self):
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)

        self.pool = AsyncConnectionPool(loop=self.loop, **MYSQL_CONFIG)

        self.loop.run_until_complete(self.get_connection_coro())
Ejemplo n.º 2
0
class AsyncioTestConnectable:
    def setUp(self):
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)

        self.pool = AsyncConnectionPool(loop=self.loop, **MYSQL_CONFIG)

        self.loop.run_until_complete(self.get_connection_coro())

    def tearDown(self):
        self.loop.run_until_complete(self.close_connection_coro())

        self.loop.close()

    @asyncio.coroutine
    def get_connection_coro(self):
        self.cnx = yield from self.pool.get()

    @asyncio.coroutine
    def close_connection_coro(self):
        yield from self.pool.shutdown()