Skip to content

How to use Pool? Please get me sample #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mtaiyi opened this issue Apr 16, 2015 · 4 comments
Closed

How to use Pool? Please get me sample #6

mtaiyi opened this issue Apr 16, 2015 · 4 comments

Comments

@mtaiyi
Copy link

mtaiyi commented Apr 16, 2015

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
Copy link
Member

methane commented Apr 16, 2015

@methane
Copy link
Member

methane commented Apr 16, 2015

@gen.coroutine
def main():
    getAll()

You forget yield.

@gen.coroutine
def main():
    yield getAll()

@methane methane closed this as completed Apr 16, 2015
@mtaiyi
Copy link
Author

mtaiyi commented Apr 17, 2015

Nothing happens when i add yield

@methane methane reopened this Apr 17, 2015
@methane
Copy link
Member

methane commented Apr 17, 2015

Thanks for reporting. Fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants