fix flask_nameko bug
This commit is contained in:
parent
4211be09be
commit
121cc2e30b
|
@ -19,15 +19,18 @@ class Connection(object):
|
|||
def __getattr__(self, attr):
|
||||
return getattr(self.connection, attr)
|
||||
|
||||
def __del__(self):
|
||||
self.connection.stop()
|
||||
|
||||
|
||||
class ConnectionPool(object):
|
||||
def __init__(
|
||||
self, get_connection, initial_connections=2, max_connections=8,
|
||||
self, connection, initial_connections=2, max_connections=8,
|
||||
recycle=None
|
||||
):
|
||||
"""
|
||||
Create a new pool
|
||||
:param func get_connection: The function that returns a connection
|
||||
:param func connection: The connection
|
||||
:param int initial_connections: The initial number of connection
|
||||
objects to create
|
||||
:param int max_connections: The maximum amount of connections
|
||||
|
@ -37,7 +40,7 @@ class ConnectionPool(object):
|
|||
:meth:`release_connection`
|
||||
constructor
|
||||
"""
|
||||
self._get_connection = get_connection
|
||||
self._connection = connection
|
||||
self._queue = Queue()
|
||||
self._current_connections = 0
|
||||
self._max_connections = max_connections
|
||||
|
@ -49,7 +52,7 @@ class ConnectionPool(object):
|
|||
self._queue.put(connection)
|
||||
|
||||
def _make_connection(self):
|
||||
ret = Connection(self._get_connection())
|
||||
ret = Connection(self._connection)
|
||||
self._current_connections += 1
|
||||
return ret
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class FlaskPooledClusterRpcProxy(PooledClusterRpcProxy):
|
|||
for key, val in app.config.items():
|
||||
match = re.match(r"NAMEKO\_(?P<name>.*)", key)
|
||||
if match:
|
||||
config[match.group('name')] = val
|
||||
config['uri'] = val
|
||||
self.configure(config)
|
||||
|
||||
self._connect_on_method_call = config.get(
|
||||
|
|
Loading…
Reference in New Issue