diff --git a/kombu/messaging.py b/kombu/messaging.py index 682e611d..961eec30 100644 --- a/kombu/messaging.py +++ b/kombu/messaging.py @@ -256,8 +256,9 @@ class Consumer(object): self.consume() return self - def __exit__(self): + def __exit__(self, exc_type, exc_val, traceback): self.cancel() + return False def consume(self, no_ack=None): """Register consumer on server. diff --git a/kombu/tests/test_messaging.py b/kombu/tests/test_messaging.py index 751f8587..c0f5d6fa 100644 --- a/kombu/tests/test_messaging.py +++ b/kombu/tests/test_messaging.py @@ -217,7 +217,9 @@ class test_Consumer(unittest.TestCase): context = consumer.__enter__() self.assertIs(context, consumer) self.assertTrue(consumer._active_tags) - consumer.__exit__() + self.assertRaises(TypeError, consumer.__exit__) + res = consumer.__exit__(None, None, None) + self.assertFalse(res) self.assertIn("basic_cancel", channel) self.assertFalse(consumer._active_tags)