diff options
author | Mehdi Abaakouk <mehdi.abaakouk@enovance.com> | 2014-12-01 11:11:05 +0100 |
---|---|---|
committer | Mehdi Abaakouk <mehdi.abaakouk@enovance.com> | 2014-12-02 08:26:17 +0100 |
commit | f3370da11a867bae287d7f549a671811e8b399ef (patch) | |
tree | a3aa3c432e30ae2fc48d98305aaa169a842c8e9f | |
parent | f2234d291f8f6643a8687eeff3bfbd2b6bbdb0e2 (diff) | |
download | oslo-messaging-f3370da11a867bae287d7f549a671811e8b399ef.tar.gz |
Don't share connection pool between driver object
Each driver instance must use it's own connection pool.
This removes the last global state of qpid and rabbitmq driver
Make the relation between classes more simple.
The previous behavior was not very safe, as explained in the bug report.
And also, this is a first step to replace this custom connection pool
handling by the kombu one.
Closes bug: #1397925
Partial bug: #1397339
Change-Id: Iecd2b39c76417d9ac081d46810f72eb6e38edfda
-rw-r--r-- | oslo/messaging/_drivers/amqp.py | 23 | ||||
-rw-r--r-- | oslo/messaging/_drivers/impl_qpid.py | 2 | ||||
-rw-r--r-- | oslo/messaging/_drivers/impl_rabbit.py | 2 |
3 files changed, 2 insertions, 25 deletions
diff --git a/oslo/messaging/_drivers/amqp.py b/oslo/messaging/_drivers/amqp.py index f198f00..a7c2210 100644 --- a/oslo/messaging/_drivers/amqp.py +++ b/oslo/messaging/_drivers/amqp.py @@ -25,7 +25,6 @@ uses AMQP, but is deprecated and predates this code. import collections import logging -import threading import uuid import six @@ -71,28 +70,6 @@ class ConnectionPool(pool.Pool): def empty(self): for item in self.iter_free(): item.close() - # Force a new connection pool to be created. - # Note that this was added due to failing unit test cases. The issue - # is the above "while loop" gets all the cached connections from the - # pool and closes them, but never returns them to the pool, a pool - # leak. The unit tests hang waiting for an item to be returned to the - # pool. The unit tests get here via the tearDown() method. In the run - # time code, it gets here via cleanup() and only appears in service.py - # just before doing a sys.exit(), so cleanup() only happens once and - # the leakage is not a problem. - del self.connection_cls.pools[self.url] - - -_pool_create_sem = threading.Lock() - - -def get_connection_pool(conf, url, connection_cls): - with _pool_create_sem: - # Make sure only one thread tries to create the connection pool. - if url not in connection_cls.pools: - connection_cls.pools[url] = ConnectionPool(conf, url, - connection_cls) - return connection_cls.pools[url] class ConnectionContext(rpc_common.Connection): diff --git a/oslo/messaging/_drivers/impl_qpid.py b/oslo/messaging/_drivers/impl_qpid.py index 28bde7c..6d4e791 100644 --- a/oslo/messaging/_drivers/impl_qpid.py +++ b/oslo/messaging/_drivers/impl_qpid.py @@ -723,7 +723,7 @@ class QpidDriver(amqpdriver.AMQPDriverBase): conf.register_opts(qpid_opts) conf.register_opts(rpc_amqp.amqp_opts) - connection_pool = rpc_amqp.get_connection_pool(conf, url, Connection) + connection_pool = rpc_amqp.ConnectionPool(conf, url, Connection) super(QpidDriver, self).__init__(conf, url, connection_pool, diff --git a/oslo/messaging/_drivers/impl_rabbit.py b/oslo/messaging/_drivers/impl_rabbit.py index 0c786ed..2f00d4f 100644 --- a/oslo/messaging/_drivers/impl_rabbit.py +++ b/oslo/messaging/_drivers/impl_rabbit.py @@ -749,7 +749,7 @@ class RabbitDriver(amqpdriver.AMQPDriverBase): conf.register_opts(rabbit_opts) conf.register_opts(rpc_amqp.amqp_opts) - connection_pool = rpc_amqp.get_connection_pool(conf, url, Connection) + connection_pool = rpc_amqp.ConnectionPool(conf, url, Connection) super(RabbitDriver, self).__init__(conf, url, connection_pool, |