File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44setup (
55 name = "Tornado-MySQL" ,
6- version = "0.5.1 " ,
6+ version = "0.5.2 " ,
77 url = 'https://github.com/PyMySQL/Tornado-MySQL' ,
88 author = 'INADA Naoki' ,
99 author_email = 'songofacandy@gmail.com' ,
Original file line number Diff line number Diff line change @@ -72,13 +72,19 @@ def _get_conn(self):
7272 if self .max_open == 0 or self ._opened_conns < self .max_open :
7373 self ._opened_conns += 1
7474 log .debug ("Creating new connection: %s" , self .stat ())
75- return connect (** self .connect_kwargs )
75+ fut = connect (** self .connect_kwargs )
76+ fut .add_done_callback (self ._on_connect ) # self._opened_conns -=1 on exception
77+ return fut
7678
7779 # Wait to other connection is released.
7880 fut = Future ()
7981 self ._waitings .append (fut )
8082 return fut
8183
84+ def _on_connect (self , fut ):
85+ if fut .exception ():
86+ self ._opened_conns -= 1
87+
8288 def _put_conn (self , conn ):
8389 if (len (self ._free_conn ) < self .max_idle and
8490 self .io_loop .time () - conn .connected_time < self .max_recycle_sec ):
You can’t perform that action at this time.
0 commit comments