title: Any reason why socket.send() hangs?
body: <p>I'm writing an mini FTP server in Python that exposes an underlying database as if it was FTP.  The flow is something like this:</p>
  
  <pre><code>sock.send("150 Here's the file you wanted\r\n")
  proc = Popen2(...)
  for parts in data:
      data_sock.send(parts)
  proc.kill()
  sock.send("226 There's the file you wanted\r\n")
  data_sock.shutdown(0)
  data_sock.close()
  </code></pre>
  
  <p>data_sock is the PASV socket that's up and working, confirmed by Wireshark.  What's actually happening is after the 163,328th byte has been sent over the data_sock, the data_sock.send() line just hangs.  I suspect the send buffer is full, but it's a mystery to me why the FTP clients wouldn't be reading from the PASV socket.</p>
  
  <p>I've included the Popen2(...) line because I've managed to reproduce <a href="http://bugs.python.org/issue3006" rel="nofollow noreferrer">http://bugs.python.org/issue3006</a> on OS X--sockets don't close until the Popen process is killed.  Not sure if this is somehow related.</p>