mirror of https://github.com/celery/kombu.git
Fix kombu.messaging.Consumer.__exit__, which didn’t conform to PEP 0343’s calling convention, and thus rendered Consumer unusable in a with statement.
This commit is contained in:
parent
f7ba3d2ea0
commit
862531f120
|
@ -256,8 +256,9 @@ class Consumer(object):
|
||||||
self.consume()
|
self.consume()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self):
|
def __exit__(self, exc_type, exc_val, traceback):
|
||||||
self.cancel()
|
self.cancel()
|
||||||
|
return False
|
||||||
|
|
||||||
def consume(self, no_ack=None):
|
def consume(self, no_ack=None):
|
||||||
"""Register consumer on server.
|
"""Register consumer on server.
|
||||||
|
|
|
@ -217,7 +217,9 @@ class test_Consumer(unittest.TestCase):
|
||||||
context = consumer.__enter__()
|
context = consumer.__enter__()
|
||||||
self.assertIs(context, consumer)
|
self.assertIs(context, consumer)
|
||||||
self.assertTrue(consumer._active_tags)
|
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.assertIn("basic_cancel", channel)
|
||||||
self.assertFalse(consumer._active_tags)
|
self.assertFalse(consumer._active_tags)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue