title: ftplib - file creation very slow: SSLError: The read operation timed out
body: <pre><code>import ftplib
  import csv
  import StringIO
  
  sio = StringIO.StringIO()
  data = csv.writer(sio)
  data.writerows(data_to_export)
  sio.seek(0)
  ftps.storbinary("STOR " + 'blah.csv', sio)
  ftps.close()
  </code></pre>
  
  <p>So the file I'm creating is only 56 lines, it creates very slowly. And when it finishes creating, I get this error:</p>
  
  <pre><code>    ftps.storbinary("STOR " + 'blah.csv', sio)
    File "/usr/lib/python2.7/ftplib.py", line 752, in storbinary
      conn.unwrap()
    File "/usr/lib/python2.7/ssl.py", line 384, in unwrap
      s = self._sslobj.shutdown()
  SSLError: The read operation timed out
  </code></pre>
  
  <p>I don't get it why it is so slow and why it gives time out, even though it creates that file.</p>
  
  <p><strong>P.S.</strong> please ask if I need to provide additional information</p>
  
  <p><strong>Update</strong>
  I also tried <code>cString</code>, but it does not improve anything as I guess its not related with writing speed.</p>
  
  <p>If there is any difference, connection to ftp is made using Implicit SSL/TLS mode (that ftp does not support Explicit SSL/TLS).</p>
  
  <p><strong>Update</strong>
  Digging deeper. That is what debugging shows for ftp:</p>
  
  <pre><code>*cmd* 'TYPE I'
  *resp* '200 Binary mode selected.'
  *cmd* 'PASV'
  *resp* '227 Entering Passive Mode (*,*,*,*,*,*)'
  *cmd* 'STOR blah.csv'
  *resp* '125 Secure data connection open; transfer starting.'
  </code></pre>
  
  <p>And then stucks at that last output till I get connection time out.</p>
  
  <p><strong>Note</strong>. My internet connection is very good, but that ftp is kind of slow. Still I guess such small file should be handled much faster than this.</p>
  
  <p><strong>Update2</strong>
  That is some weird ftp. Trying unsecure ftp connection, files are uploaded properly and fast. That Implicit connection has something to do with this slow performance and time outs.</p>