Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tornado_mysql/pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

DEBUG = False


def _debug(*msg):
if DEBUG:
print(*msg)
Expand All @@ -31,9 +30,9 @@ class Pool(object):

def __init__(self,
connect_kwargs,
max_idle_connections=1,
max_open_connections,
max_idle_connections=0,
max_recycle_sec=3600,
max_open_connections=0,
io_loop=None,
):
"""
Expand All @@ -47,7 +46,8 @@ def __init__(self,
self.io_loop = io_loop or IOLoop.current()
self.connect_kwargs = connect_kwargs
self.max_idle = max_idle_connections
self.max_open = max_open_connections
if max_open_connections <= 0:
raise ValueError("max idle or open connections not initialized properly")
self.max_recycle_sec = max_recycle_sec

self._opened_conns = 0
Expand All @@ -73,7 +73,7 @@ def _get_conn(self):
return fut

# Open new connection
if self.max_open == 0 or self._opened_conns < self.max_open:
if self._opened_conns < self.max_open:
self._opened_conns += 1
_debug("Creating new connection:", self.stat())
return connect(**self.connect_kwargs)
Expand Down