File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ from tornado import gen
2525import tormysql
2626
2727pool = tormysql.ConnectionPool(
28- max_connections = 20,
28+ max_connections = 20, #max open connections
29+ idle_seconds = 7200, #conntion idle timeout time, 0 is not timeout
2930 host = "127.0.0.1",
3031 user = "root",
3132 passwd = "TEST",
@@ -34,7 +35,7 @@ pool = tormysql.ConnectionPool(
3435)
3536
3637@gen.coroutine
37- def connect ():
38+ def test ():
3839 conn = yield pool.Connection()
3940 cursor = conn.cursor()
4041 yield cursor.execute("SELECT * FROM test")
@@ -43,11 +44,10 @@ def connect():
4344 conn.close()
4445
4546 print datas
46-
47- def start():
48- connect()
47+
48+ yield pool.close()
4949
5050ioloop = IOLoop.instance()
51- ioloop.add_callback(start )
51+ ioloop.add_callback(test )
5252ioloop.start()
5353```
Original file line number Diff line number Diff line change 1212import tormysql
1313
1414pool = tormysql .ConnectionPool (
15+ max_connections = 20 ,
16+ idle_seconds = 7200 ,
1517 host = "127.0.0.1" ,
1618 user = "root" ,
1719 passwd = "123456" ,
You can’t perform that action at this time.
0 commit comments