python 3.6 socket pickle data was truncated
python 3.6 socket pickle data was truncated
the problem is that if the size of the pickled data is > 4096 you only get the first part of the pickled data (hence the pickle data was truncated
message youre getting)
You have to append the data and pickle it only when the reception is complete, for example like this:
data = b
while True:
packet = s.recv(4096)
if not packet: break
data += packet
data_arr = pickle.loads(data)
print (data_arr)
s.close()
increasing a bytes object is not very performant, would be better to store the parts in a list of objects, then join
, though. Faster variant:
data = []
while True:
packet = s.recv(4096)
if not packet: break
data.append(packet)
data_arr = pickle.loads(b.join(data))
print (data_arr)
s.close()
In the most Simple words. the file that you are trying to load is not complete. Either you have not downlaoded it correctly or its just that your pickle file is corrupt. You can create a new pickle to solve this issue