Skip to content

Commit 7b10471

Browse files
committed
Close connection when conn.begin() fails
1 parent 45c2ed0 commit 7b10471

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tornado_mysql/pools.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ def begin(self):
144144
:rtype: Future
145145
"""
146146
conn = yield self._get_conn()
147-
yield conn.begin()
147+
try:
148+
yield conn.begin()
149+
except:
150+
self._close_conn(conn)
151+
raise
148152
trx = Transaction(self, conn)
149153
raise Return(trx)
150154

0 commit comments

Comments
 (0)