summaryrefslogtreecommitdiffstats
path: root/nova/rpc.py
diff options
context:
space:
mode:
authortermie <github@anarkystic.com>2011-05-26 15:08:53 -0700
committertermie <github@anarkystic.com>2011-05-26 15:08:53 -0700
commitd7e0b45a9bc415e87beee32f10c8d6bdff9819ed (patch)
treea1feb6f79ae505a3abd60d401b01a70789edfe8b /nova/rpc.py
parentfeb04f0117450bcd6e8f4966f4487575073be41c (diff)
downloadnova-d7e0b45a9bc415e87beee32f10c8d6bdff9819ed.tar.gz
nova-d7e0b45a9bc415e87beee32f10c8d6bdff9819ed.tar.xz
nova-d7e0b45a9bc415e87beee32f10c8d6bdff9819ed.zip
changes per review
Diffstat (limited to 'nova/rpc.py')
-rw-r--r--nova/rpc.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/nova/rpc.py b/nova/rpc.py
index 493978e57..1ec495bc8 100644
--- a/nova/rpc.py
+++ b/nova/rpc.py
@@ -28,6 +28,7 @@ import json
import sys
import time
import traceback
+import types
import uuid
from carrot import connection as carrot_connection
@@ -228,7 +229,7 @@ class AdapterConsumer(Consumer):
rval = node_func(context=ctxt, **node_args)
if msg_id:
# Check if the result was a generator
- if hasattr(rval, 'send'):
+ if isinstance(rval, types.GeneratorType):
for x in rval:
msg_reply(msg_id, x, None)
else:
@@ -236,7 +237,7 @@ class AdapterConsumer(Consumer):
# This final None tells multicall that it is done.
msg_reply(msg_id, None, None)
- elif hasattr(rval, 'send'):
+ elif isinstance(rval, types.GeneratorType):
# NOTE(vish): this iterates through the generator
list(rval)
except Exception as e:
@@ -281,11 +282,11 @@ class FanoutAdapterConsumer(AdapterConsumer):
class ConsumerSet(object):
"""Groups consumers to listen on together on a single connection."""
- def __init__(self, conn, consumer_list):
+ def __init__(self, connection, consumer_list):
self.consumer_list = set(consumer_list)
self.consumer_set = None
self.enabled = True
- self.init(conn)
+ self.init(connection)
def init(self, conn):
if not conn:
@@ -316,8 +317,7 @@ class ConsumerSet(object):
running = False
break
except Exception as e:
- LOG.error(_("Received exception %s " % type(e) + \
- "while processing consumer"))
+ LOG.exception(_("Exception while processing consumer"))
self.reconnect()
# Break to outer loop
break
@@ -534,7 +534,10 @@ def call(context, topic, msg):
"""Sends a message on a topic and wait for a response."""
rv = multicall(context, topic, msg)
# NOTE(vish): return the last result from the multicall
- return list(rv)[-1]
+ rv = list(rv)
+ if not rv:
+ return
+ return rv[-1]
def cast(context, topic, msg):