title: Pickle EOFError: Ran out of input when recv from a socket
body: <p>I am running a very simple python (3.x) client-server program (both locally on my PC) for a school project (not intended for the real world) which just sends messages back-and-forth (like view customers, add customer, delete customer, etc... real basic).</p>
  
  <p>Sometimes the data can be multiple records which I had stored as namedTuples (just made sense) and then went down the path of using Pickle to transfer then.</p>
  
  <p>So for example on the client I do something like this:</p>
  
  <pre><code>s.send(message.encode('utf-8'))
  pickledResponse = s.recv(4096);
  response = pickle.loads(pickledResponse)
  </code></pre>
  
  <p>Now ever so often I get the following error:</p>
  
  <pre><code>response = pickle.loads(pickledResponse)
  EOFError: Ran out of input
  </code></pre>
  
  <p>My fear is that this has something to do with my socket (TCP) transfer and maybe somehow I am not getting all the data in time for my pickle.loads - make sense? If not I am really lost as to why this would be happening so inconsistently.</p>
  
  <p>However, even if I am right I am not sure how to fix it (quickly), I was considering dropping pickle and just using strings (but couldn't this suffer from the same fate)? Does anyone have any suggestions?</p>
  
  <p>Really my message are pretty basic - usually just a command and some small data like "1=John" which means command (1) which is FIND command and then "John" and it returns the record (name, age, etc...) of John (as a namedTuple - but honestly this isn't mandatory).</p>
  
  <p>Any suggestions or help would be much appreciated, looking for a quick fix...</p>