Skip to content

Commit

Permalink
Another py3 fix.
Browse files Browse the repository at this point in the history
Turns out that `stomper` only handles unicode/str types and stumbles on bytestrings.
  • Loading branch information
ralphbean committed Jun 18, 2018
1 parent accc230 commit dc90608
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions moksha.hub/moksha/hub/stomp/stomp.py
Expand Up @@ -28,6 +28,7 @@

import logging

import six
from twisted.internet.protocol import ClientFactory

from moksha.hub.stomp.protocol import StompProtocol
Expand Down Expand Up @@ -162,6 +163,9 @@ def stop_heartbeat(self):
self._heartbeat_enabled = False

def send_message(self, topic, message, **headers):
# Convert any utf-8 encoded payloads back to unicode. stomper can't handle bytestrings
topic = topic.decode('utf-8') if isinstance(topic, six.binary_type) else topic
message = message.decode('utf-8') if isinstance(message, six.binary_type) else message
f = stomper.Frame()
f.unpack(stomper.send(topic, message))
if not self.proto:
Expand Down

0 comments on commit dc90608

Please sign in to comment.