change the behavior of calling a multicall
This commit is contained in:
@@ -236,6 +236,9 @@ class AdapterConsumer(Consumer):
|
|||||||
|
|
||||||
# This final None tells multicall that it is done.
|
# This final None tells multicall that it is done.
|
||||||
msg_reply(msg_id, None, None)
|
msg_reply(msg_id, None, None)
|
||||||
|
elif hasattr(rval, 'send'):
|
||||||
|
# NOTE(vish): this iterates through the generator
|
||||||
|
list(rval)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception('Exception during message handling')
|
logging.exception('Exception during message handling')
|
||||||
if msg_id:
|
if msg_id:
|
||||||
@@ -530,9 +533,8 @@ class MulticallWaiter(object):
|
|||||||
def call(context, topic, msg):
|
def call(context, topic, msg):
|
||||||
"""Sends a message on a topic and wait for a response."""
|
"""Sends a message on a topic and wait for a response."""
|
||||||
rv = multicall(context, topic, msg)
|
rv = multicall(context, topic, msg)
|
||||||
for x in rv:
|
# NOTE(vish): return the last result from the multicall
|
||||||
rv.close()
|
return list(rv)[-1]
|
||||||
return x
|
|
||||||
|
|
||||||
|
|
||||||
def cast(context, topic, msg):
|
def cast(context, topic, msg):
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ class RpcTestCase(test.TestCase):
|
|||||||
value = 42
|
value = 42
|
||||||
result = rpc.call(self.context, 'test', {"method": "echo_three_times",
|
result = rpc.call(self.context, 'test', {"method": "echo_three_times",
|
||||||
"args": {"value": value}})
|
"args": {"value": value}})
|
||||||
self.assertEqual(value, result)
|
self.assertEqual(value + 2, result)
|
||||||
|
|
||||||
def test_call_succeed_despite_multiple_returns_yield(self):
|
def test_call_succeed_despite_multiple_returns_yield(self):
|
||||||
value = 42
|
value = 42
|
||||||
result = rpc.call(self.context, 'test',
|
result = rpc.call(self.context, 'test',
|
||||||
{"method": "echo_three_times_yield",
|
{"method": "echo_three_times_yield",
|
||||||
"args": {"value": value}})
|
"args": {"value": value}})
|
||||||
self.assertEqual(value, result)
|
self.assertEqual(value + 2, result)
|
||||||
|
|
||||||
def test_multicall_succeed_once(self):
|
def test_multicall_succeed_once(self):
|
||||||
value = 42
|
value = 42
|
||||||
|
|||||||
Reference in New Issue
Block a user