summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortermie <github@anarkystic.com>2011-05-25 15:43:04 -0700
committertermie <github@anarkystic.com>2011-05-25 15:43:04 -0700
commitfeb04f0117450bcd6e8f4966f4487575073be41c (patch)
tree6ed0cd4ff611cc5c772a4daade57d41262fdbb6b
parenta05e8e7587e42633e8459fd050eee3a4da247330 (diff)
change the behavior of calling a multicall
-rw-r--r--nova/rpc.py8
-rw-r--r--nova/tests/test_rpc.py4
2 files changed, 7 insertions, 5 deletions
diff --git a/nova/rpc.py b/nova/rpc.py
index 8d14494f0..493978e57 100644
--- a/nova/rpc.py
+++ b/nova/rpc.py
@@ -236,6 +236,9 @@ class AdapterConsumer(Consumer):
# This final None tells multicall that it is done.
msg_reply(msg_id, None, None)
+ elif hasattr(rval, 'send'):
+ # NOTE(vish): this iterates through the generator
+ list(rval)
except Exception as e:
logging.exception('Exception during message handling')
if msg_id:
@@ -530,9 +533,8 @@ class MulticallWaiter(object):
def call(context, topic, msg):
"""Sends a message on a topic and wait for a response."""
rv = multicall(context, topic, msg)
- for x in rv:
- rv.close()
- return x
+ # NOTE(vish): return the last result from the multicall
+ return list(rv)[-1]
def cast(context, topic, msg):
diff --git a/nova/tests/test_rpc.py b/nova/tests/test_rpc.py
index 8523b409c..35f4a64d9 100644
--- a/nova/tests/test_rpc.py
+++ b/nova/tests/test_rpc.py
@@ -51,14 +51,14 @@ class RpcTestCase(test.TestCase):
value = 42
result = rpc.call(self.context, 'test', {"method": "echo_three_times",
"args": {"value": value}})
- self.assertEqual(value, result)
+ self.assertEqual(value + 2, result)
def test_call_succeed_despite_multiple_returns_yield(self):
value = 42
result = rpc.call(self.context, 'test',
{"method": "echo_three_times_yield",
"args": {"value": value}})
- self.assertEqual(value, result)
+ self.assertEqual(value + 2, result)
def test_multicall_succeed_once(self):
value = 42