WEBSOCKET_HOST decode error on Python 3
Closed this issue · 2 comments
mmurdoch commented
On Python 3 (3.4.3) a simple stream client like this:
from __future__ import print_function
from datasift import Client
ds = Client("Username", "API Key")
@ds.on_delete
def on_delete(interaction):
print( 'Deleted interaction %s ' % interaction)
@ds.on_open
def on_open():
print( 'Streaming ready, can start subscribing')
csdl = 'interaction.content contains "music"'
stream = ds.compile(csdl)['hash']
@ds.subscribe(stream)
def subscribe_to_hash(msg):
print(msg)
@ds.on_closed
def on_close(wasClean, code, reason):
print( 'Streaming connection closed')
@ds.on_ds_message
def on_ds_message(msg):
print( 'DS Message %s' % msg)
ds.start_stream_subscriber()
throws the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
File "/usr/local/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/datasift-python/datasift/client.py", line 237, in _stream
options = ssl.optionsForClientTLS(hostname=WEBSOCKET_HOST.decode("utf-8"))
AttributeError: 'str' object has no attribute 'decode'