diff --git a/chassis/flask_nameko/connection_pool.py b/chassis/flask_nameko/connection_pool.py index 203f1a3..a47100e 100644 --- a/chassis/flask_nameko/connection_pool.py +++ b/chassis/flask_nameko/connection_pool.py @@ -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 diff --git a/chassis/flask_nameko/proxies.py b/chassis/flask_nameko/proxies.py index 0ea2a69..6a23ee3 100644 --- a/chassis/flask_nameko/proxies.py +++ b/chassis/flask_nameko/proxies.py @@ -71,7 +71,7 @@ class FlaskPooledClusterRpcProxy(PooledClusterRpcProxy): for key, val in app.config.items(): match = re.match(r"NAMEKO\_(?P.*)", key) if match: - config[match.group('name')] = val + config['uri'] = val self.configure(config) self._connect_on_method_call = config.get(