Last active
March 23, 2016 12:49
-
-
Save jettify/36584872aabaa2e5f8bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@asyncio.coroutine | |
def do_select(pool, i): | |
with (yield from pool) as conn: | |
cur = yield from conn.cursor() | |
yield from cur.execute("SELECT 10") | |
yield from cur.close() | |
@asyncio.coroutine | |
def test_example(loop): | |
pool = yield from aiomysql.create_pool(host='127.0.0.1', port=3306, | |
minsize = 20, maxsize=20 | |
user='root', password='', | |
db='mysql', loop=loop) | |
coros = [do_select(pool, i) for i in range(20)] | |
yield from asyncio.gather(*coros, loop=loop | |
pool.close() | |
yield from pool.wait_closed() | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(test_example(loop)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment