[impl_rabbit] Remove deprecated get_expiration method

This method is called on each message publishing and as shows
profiling (CProfile), the method is time-consuming, because it
uses pkg_resources module.

As we uses kombu>=3.0.25 since Mitaka, we no longer need in it.

Change-Id: I00723a3de81249946a8220ad47129f059d6d544f
This commit is contained in:
Kirill Bespalov 2016-05-31 13:44:36 +03:00
parent acb398e317
commit 034c8f03aa

View File

@ -33,8 +33,6 @@ import kombu.messaging
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import netutils
from oslo_utils import versionutils
import pkg_resources
import six
from six.moves.urllib import parse
@ -1143,18 +1141,6 @@ class Connection(object):
with self._connection_lock:
self.ensure(method, retry=retry, error_callback=_error_callback)
def _get_expiration(self, timeout):
# NOTE(gcb) kombu accept TTL as seconds instead of millisecond since
# version 3.0.25, so do conversion according to kombu version.
# TODO(gcb) remove this workaround when all supported branches
# with requirement kombu >=3.0.25
if timeout is not None:
kombu_version = pkg_resources.get_distribution('kombu').version
if not versionutils.is_compatible('3.0.25', kombu_version):
timeout = int(timeout * 1000)
return timeout
def _publish(self, exchange, msg, routing_key=None, timeout=None):
"""Publish a message."""
@ -1174,7 +1160,7 @@ class Connection(object):
self._producer.publish(msg,
exchange=exchange,
routing_key=routing_key,
expiration=self._get_expiration(timeout),
expiration=timeout,
compression=self.kombu_compression)
def _publish_and_creates_default_queue(self, exchange, msg,