From 862531f12020b0f77e1b4da821f540ef5108c422 Mon Sep 17 00:00:00 2001 From: Ian Eure Date: Thu, 31 Mar 2011 13:34:05 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20kombu.messaging.Consumer.=5F=5Fexit=5F=5F?= =?UTF-8?q?,=20which=20didn=E2=80=99t=20conform=20to=20PEP=200343=E2=80=99?= =?UTF-8?q?s=20calling=20convention,=20and=20thus=20rendered=20Consumer=20?= =?UTF-8?q?unusable=20in=20a=20with=20statement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kombu/messaging.py | 3 ++- kombu/tests/test_messaging.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) 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)