summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorEric Windisch <eric@cloudscaling.com>2013-01-28 11:58:23 -0500
committerEric Windisch <eric@cloudscaling.com>2013-01-31 14:30:57 -0500
commit4552f1064fa50228ecdc4b5cf43c24f5401040b7 (patch)
tree308e24a44c5b6183160cac68dff6ab37c7875f17 /openstack
parentc29263c4a81d2e71a3d6e36eb32e5df9d2c8fb05 (diff)
downloadoslo-4552f1064fa50228ecdc4b5cf43c24f5401040b7.tar.gz
oslo-4552f1064fa50228ecdc4b5cf43c24f5401040b7.tar.xz
oslo-4552f1064fa50228ecdc4b5cf43c24f5401040b7.zip
Use bytes instead of str
Clarifies that str is the wrong datatype for passing messages over ZeroMQ. This distinction will be more important with the eventual migration to Python 3.0, but (I hope) this also helps clarify WHY typecasting is performed before sending messages. Change-Id: I4dd4661a5730a24ba7b514520b0429b721b05e9c
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/rpc/impl_zmq.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py
index 86d2bc5..e788078 100644
--- a/openstack/common/rpc/impl_zmq.py
+++ b/openstack/common/rpc/impl_zmq.py
@@ -90,7 +90,7 @@ def _serialize(data):
Error if a developer passes us bad data.
"""
try:
- return str(jsonutils.dumps(data, ensure_ascii=True))
+ return jsonutils.dumps(data, ensure_ascii=True)
except TypeError:
LOG.error(_("JSON serialization failed."))
raise
@@ -220,8 +220,7 @@ class ZmqClient(object):
def cast(self, msg_id, topic, data, serialize=True, force_envelope=False):
if serialize:
data = rpc_common.serialize_msg(data, force_envelope)
- self.outq.send([str(msg_id), str(topic), str('cast'),
- _serialize(data)])
+ self.outq.send(map(bytes, (msg_id, topic, 'cast', _serialize(data))))
def close(self):
self.outq.close()
@@ -445,7 +444,7 @@ class ZmqProxy(ZmqBaseReactor):
msg_id = inside[-1]['args']['msg_id']
response = inside[-1]['args']['response']
LOG.debug(_("->response->%s"), response)
- data = [str(msg_id), _serialize(response)]
+ data = map(bytes, (msg_id, _serialize(response)))
else:
sock_type = zmq.PUSH