diff --git a/tornado_mysql/pools.py b/tornado_mysql/pools.py index f7c4b69..d8ce76a 100644 --- a/tornado_mysql/pools.py +++ b/tornado_mysql/pools.py @@ -14,7 +14,6 @@ DEBUG = False - def _debug(*msg): if DEBUG: print(*msg) @@ -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, ): """ @@ -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 @@ -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)