diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-02-11 13:21:40 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-02-11 13:21:40 +0000 |
commit | fafe97709cb2176c70f21d9c23f64774b42ef768 (patch) | |
tree | 2aceb09633fab4dea2635ef4cfcc8bce691488f6 | |
parent | ad417d3e02411f188023ac6e82a1e4fd4a5c5a28 (diff) | |
parent | 0fb20d8d49f21bee455420ec5870145722c0e9db (diff) | |
download | oslo-messaging-fafe97709cb2176c70f21d9c23f64774b42ef768.tar.gz |
Merge "Correctly set socket timeout for publishing"
-rw-r--r-- | oslo_messaging/_drivers/impl_rabbit.py | 12 | ||||
-rw-r--r-- | oslo_messaging/tests/drivers/test_impl_rabbit.py | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index 11821f8..8ac1078 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -810,7 +810,17 @@ class Connection(object): # or the producer.send return only when the system socket # timeout if reach. kombu doesn't allow use to customise this # timeout so for py-amqp we tweak ourself - sock = getattr(self.connection.transport, 'sock', None) + # NOTE(dmitryme): Current approach works with amqp==1.4.9 and + # kombu==3.0.33. Once the commit below is released, we should + # try to set the socket timeout in the constructor: + # https://github.com/celery/py-amqp/pull/64 + try: + sock = self.channel.connection.sock + except AttributeError as e: + # Level is set to debug because otherwise we would spam the logs + LOG.debug('Failed to get socket attribute: %s' % str(e)) + sock = None + if sock: orig_timeout = sock.gettimeout() sock.settimeout(timeout) diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py index 1a6a5e3..dbd1eca 100644 --- a/oslo_messaging/tests/drivers/test_impl_rabbit.py +++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py @@ -90,11 +90,11 @@ class TestHeartbeat(test_utils.BaseTestCase): if not heartbeat_side_effect: self.assertEqual(1, fake_ensure_connection.call_count) - self.assertEqual(2, fake_logger.debug.call_count) + self.assertEqual(3, fake_logger.debug.call_count) self.assertEqual(0, fake_logger.info.call_count) else: self.assertEqual(2, fake_ensure_connection.call_count) - self.assertEqual(2, fake_logger.debug.call_count) + self.assertEqual(3, fake_logger.debug.call_count) self.assertEqual(1, fake_logger.info.call_count) self.assertIn(mock.call(info, mock.ANY), fake_logger.info.mock_calls) |