Avoid unnecessary use of items()

The key, value pair returned by items() wasn't used here,
so rewrite the logic to just iterate over the keys, filtered
by the type.

Change-Id: I7512ea93ac794d161a4cd9944546d6ca035a12cf
This commit is contained in:
Dirk Mueller 2018-10-28 17:29:56 +01:00
parent 13fa4f5ab1
commit 344ec5e8bb
1 changed files with 6 additions and 5 deletions

View File

@ -34,6 +34,7 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import eventletutils
import six
import six.moves
from six.moves.urllib import parse
import oslo_messaging
@ -786,11 +787,11 @@ class Connection(object):
"""Close/release this connection."""
self._heartbeat_stop()
if self.connection:
for consumer, tag in self._consumers.items():
if consumer.type == 'fanout':
LOG.debug('[connection close] Deleting fanout '
'queue: %s ' % consumer.queue.name)
consumer.queue.delete()
for consumer in six.moves.filter(lambda c: c.type == 'fanout',
self._consumers):
LOG.debug('[connection close] Deleting fanout '
'queue: %s ' % consumer.queue.name)
consumer.queue.delete()
self._set_current_channel(None)
self.connection.release()
self.connection = None