From 65dc58505a1e11530e52a90d0399287b582b7764 Mon Sep 17 00:00:00 2001 From: Ask Solem Date: Thu, 28 Jul 2011 11:46:44 +0100 Subject: [PATCH] Producer now works as a context manager. --- kombu/messaging.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kombu/messaging.py b/kombu/messaging.py index b78a720d..cf3036e4 100644 --- a/kombu/messaging.py +++ b/kombu/messaging.py @@ -138,6 +138,12 @@ class Producer(object): self.channel = channel self.exchange.revive(channel) + def __enter__(self): + return self + + def __exit__(self, *exc_info): + self.close() + def close(self): pass