Add a transport cleanup() method
Pretty obvious that we need this. The rabbit/qpid implementations just empty the connection pool, in the same way their module-level cleanup() methods do now. Change-Id: I70ba5cab3eb7a30f74cdd6cafe60087769a77b57
This commit is contained in:
parent
e987525dc0
commit
1f0874857c
@ -322,3 +322,8 @@ class AMQPDriverBase(base.BaseDriver):
|
||||
conn.declare_fanout_consumer(target.topic, listener)
|
||||
|
||||
return listener
|
||||
|
||||
def cleanup(self):
|
||||
if self._connection_pool:
|
||||
self._connection_pool.empty()
|
||||
self._connection_pool = None
|
||||
|
@ -72,3 +72,7 @@ class BaseDriver(object):
|
||||
@abc.abstractmethod
|
||||
def listen(self, target):
|
||||
"""Construct a Listener for the given target."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def cleanup(self):
|
||||
"""Release all resources."""
|
||||
|
@ -164,3 +164,6 @@ class FakeDriver(base.BaseDriver):
|
||||
self._default_exchange)
|
||||
|
||||
return FakeListener(self, target, exchange)
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
@ -85,6 +85,10 @@ class Transport(object):
|
||||
def _listen(self, target):
|
||||
return self._driver.listen(target)
|
||||
|
||||
def cleanup(self):
|
||||
"""Release all resources associated with this transport."""
|
||||
self._driver.cleanup()
|
||||
|
||||
|
||||
class InvalidTransportURL(exceptions.MessagingException):
|
||||
"""Raised if transport URL is invalid."""
|
||||
|
@ -29,9 +29,6 @@ class TestRabbitDriver(test_utils.BaseTestCase):
|
||||
self.config(rpc_backend='rabbit')
|
||||
self.config(fake_rabbit=True)
|
||||
|
||||
# FIXME(markmc): this should be a cleanup method on the driver itself
|
||||
self.addCleanup(rabbit_driver.cleanup)
|
||||
|
||||
def test_driver_load(self):
|
||||
transport = messaging.get_transport(self.conf)
|
||||
self.assertTrue(isinstance(transport._driver,
|
||||
@ -39,6 +36,8 @@ class TestRabbitDriver(test_utils.BaseTestCase):
|
||||
|
||||
def test_send_receive(self):
|
||||
transport = messaging.get_transport(self.conf)
|
||||
self.addCleanup(transport.cleanup)
|
||||
|
||||
driver = transport._driver
|
||||
|
||||
target = messaging.Target(topic='testtopic')
|
||||
|
Loading…
Reference in New Issue
Block a user