Blob Blame History Raw
From 48a07680b46b9973cd7de1b30ae80bd93861e1bb Mon Sep 17 00:00:00 2001
From: Chris Behrens <cbehrens@codestud.com>
Date: Wed, 25 Apr 2012 17:34:53 +0000
Subject: [PATCH] Don't leak RPC connections on timeouts or other exceptions

Fixes bug 968843

Change-Id: I9e0f1e306cab203bf4c865050b7a45f96127062e
---
 nova/rpc/amqp.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/nova/rpc/amqp.py b/nova/rpc/amqp.py
index 444ade4..4ebd9a4 100644
--- a/nova/rpc/amqp.py
+++ b/nova/rpc/amqp.py
@@ -39,6 +39,7 @@ from nova import flags
 from nova import local
 from nova import log as logging
 import nova.rpc.common as rpc_common
+from nova import utils
 
 LOG = logging.getLogger(__name__)
 
@@ -296,7 +297,11 @@ class MulticallWaiter(object):
         if self._done:
             raise StopIteration
         while True:
-            self._iterator.next()
+            try:
+                self._iterator.next()
+            except Exception:
+                with utils.save_and_reraise_exception():
+                    self.done()
             if self._got_ending:
                 self.done()
                 raise StopIteration