Unpickle an object received from socket leads to "Ran out of input"

Viewed 45

I am sending a dictionary across network using sockets. The client sends a pickled dictionary and then the server has to unpickle it.

def getRequest(conn):
    request = b''
    while True:
        part = conn.recv(10240)
        if len(part) == 0:
            break
        request += part
    request = pickle.loads(request)
    return request

Above is the server side code which receives the request. The error I'm getting is on this line:

request = pickle.loads(request)

And the error is:

Exception ignored in thread started by: <function main at 0x7f85e6a888b0>
Traceback (most recent call last):
  File "/home/w0rk5107h/Documents/AK-Daily/main/server/server.py", line 33, in main
    request = pickle.loads(request)
EOFError: Ran out of input

This exact method has worked for in the past but I don't know why it is not working now.

0 Answers
Related