I need to send a pickled python dictionary containing several, large Pandas Dataframes over a websocket (Python API at both ends). To improve performance, I would like to compress the pickled object before sending it over the websocket. However, when doing this, the received message is always None.
Client:
df = pd.DataFrame({'a':[1,2,3,4]})
d = dict(b=df)
msg = zlib.compress(pickle.dumps(d),5)
socket.send(msg)
Server:
msg = socket.receive()
# msg is always None when called with client code above.
data = pickle.loads(zlib.decompress(msg))
Is there a better way to do this? I am using gevent-websocket through the Flask-Sockets framework.