How to use Pool? Please get me sample
mtaiyi opened this issue · 4 comments
mtaiyi commented
my code :
#!/usr/bin/env python
from __future__ import print_function
from tornado import ioloop, gen
from tornado_mysql import pools
pools.DEBUG = True
POOL = pools.Pool(
dict(host='127.0.0.1', port=3306, user='root', passwd='123456', db='lottery'),
max_idle_connections=1,
max_recycle_sec=3)
@gen.coroutine
def getAll():
cur=yield POOL.execute("SELECT redball1 FROM lottery")
print(cur.fetchall())
@gen.coroutine
def main():
getAll()
ioloop.IOLoop.current().run_sync(main)
print(POOL._opened_conns)
But print is "0".why
methane commented
Example is here: https://github.com/PyMySQL/Tornado-MySQL/blob/master/example/pool.py
methane commented
@gen.coroutine
def main():
getAll()
You forget yield
.
@gen.coroutine
def main():
yield getAll()
mtaiyi commented
Nothing happens when i add yield
methane commented
Thanks for reporting. Fixed in master.