fix flask_nameko bug 3
This commit is contained in:
parent
3c56d3766b
commit
81de5dcd60
|
@ -19,18 +19,15 @@ class Connection(object):
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return getattr(self.connection, attr)
|
return getattr(self.connection, attr)
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
self.connection.stop()
|
|
||||||
|
|
||||||
|
|
||||||
class ConnectionPool(object):
|
class ConnectionPool(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, connection, initial_connections=2, max_connections=8,
|
self, get_connection, initial_connections=2, max_connections=8,
|
||||||
recycle=None
|
recycle=None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create a new pool
|
Create a new pool
|
||||||
:param func connection: The connection
|
:param func get_connection: The function that returns a connection
|
||||||
:param int initial_connections: The initial number of connection
|
:param int initial_connections: The initial number of connection
|
||||||
objects to create
|
objects to create
|
||||||
:param int max_connections: The maximum amount of connections
|
:param int max_connections: The maximum amount of connections
|
||||||
|
@ -40,7 +37,7 @@ class ConnectionPool(object):
|
||||||
:meth:`release_connection`
|
:meth:`release_connection`
|
||||||
constructor
|
constructor
|
||||||
"""
|
"""
|
||||||
self._connection = connection
|
self._get_connection = get_connection
|
||||||
self._queue = Queue()
|
self._queue = Queue()
|
||||||
self._current_connections = 0
|
self._current_connections = 0
|
||||||
self._max_connections = max_connections
|
self._max_connections = max_connections
|
||||||
|
@ -52,7 +49,7 @@ class ConnectionPool(object):
|
||||||
self._queue.put(connection)
|
self._queue.put(connection)
|
||||||
|
|
||||||
def _make_connection(self):
|
def _make_connection(self):
|
||||||
ret = Connection(self._connection)
|
ret = Connection(self._get_connection())
|
||||||
self._current_connections += 1
|
self._current_connections += 1
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue