error when sending pickled data

28 views
Skip to first unread message

Imran Akbar

unread,
Jun 16, 2013, 11:54:24 AM6/16/13
to ws...@googlegroups.com
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 = Client('ws://54.214.125.115:8888/stream', protocols=['http-only', 'chat'])
        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
Reply all
Reply to author
Forward
0 new messages