change the behavior of calling a multicall

This commit is contained in:
termie
2011-05-25 15:43:04 -07:00
parent 22e1bdcda6
commit bb5e80112b
2 changed files with 7 additions and 5 deletions

View File

@@ -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):

View File

@@ -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