Hi,
I'm using ws4py inside of a Python web app that sends data to another server running Tornado.
When I send a simple string like 'test', it works just fine.
But when I send a longer string of pickled data, it fails with this error:
ERROR:tornado.application:Exception in callback <functools.partial object at 0x7ff474169838>
Traceback (most recent call last):
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/tornado/ioloop.py", line 458, in _run_callback
callback()
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
raise_exc_info(exc)
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
ret = fn(*args, **kwargs)
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/tornado/iostream.py", line 341, in wrapper
callback(*args)
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
raise_exc_info(exc)
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
ret = fn(*args, **kwargs)
File "/home/imran/Code/web/venv/local/lib/python2.7/site-packages/ws4py/client/tornadoclient.py", line 106, in __stream_closed
self._cleanup()
AttributeError: 'Client' object has no attribute '_cleanup'
this is the relevant code:
class Connection(threading.Thread):
def __init__(self):
super(Connection, self).__init__()
def run(self):
self.ws.connect()
ioloop.IOLoop.instance().start()
def send(self, data):
self.ws.send_data(data)
class Client(TornadoWebSocketClient):
def send_data(self, data):
self.send(data)
def received_message(self, m):
print m
def closed(self, code, reason=None):
ioloop.IOLoop.instance().stop()
connection = Connection()
connection.daemon = True
connection.start()
f = StringIO.StringIO()
p = MyPickler(f)
p.dump(data)
pickled_data = f.getvalue()
connection.send(pickled_data)
Any suggestions?
thanks,
imran