ftpilb.FTP.stor...() freeze mystery

Anthra Norell anthra.norell at bluewin.ch
Thu Oct 29 17:18:30 CET 2009

Gabriel Genellina wrote:
> En Wed, 28 Oct 2009 08:05:22 -0300, Anthra Norell 
> <anthra.norell at bluewin.ch> escribió:
>> Gabriel Genellina wrote:
>>> En Tue, 27 Oct 2009 07:53:36 -0300, Anthra Norell
>>> <anthra.norell at bluewin.ch> escribió:
>>>> I am trying to upload a bunch of web pages to a hosting 
>>>> service.[...]  I wrote a loop that iterates through the file names 
>>>> and calls either of the stor... () methods as appropriate. The loop 
>>>> successfully uploads eight of some twenty files and then freezes. 
>>>> Ctrl-C doesn't unlock the freeze. I have to kill the IDLE window
>> freezes are less predictable than it seemed in the beginning. On one 
>> occasion it occurred after the transfer of a single file from the 
>> IDLE command line (my_ftp_object.storlines ("STOR file_name", f). The 
>> file did upload. So the freezes seem to occur after a successful 
>> transfer.
> In this thread from last month, Sean DiZazzo shows how to add a 
> timeout parameter to storbinary:
> http://comments.gmane.org/gmane.comp.python.general/639258
> Do the same with storlines and see whether it helps.
Thanks a million! Here's a way out by the look of it. As the devil is in 
the details I get an error that indicates an inconsistency in my ftplib 
library (2.4) (*** marks my comments):

Traceback (most recent call last):
 File "<pyshell#65>", line 1, in -toplevel-
   d2jm = upload.run (1)
 File "I:/DOK/projects/WEB/JM\upload.py", line 369, in run
   D2JM.copy_1_2 (do)
 File "I:/DOK/projects/WEB/JM\upload.py", line 342, in copy_1_2
   try: self.FS2.storbinary ('STOR %s' % name, f, timeout = timeout)   
*** Here's the call to the overwritten method with the timeout.
 File "I:/DOK/projects/WEB/JM\upload.py", line 440, in storbinary
   self.connection = self.transfercmd (command)   *** command is 'STOR 
(target file name)'. Control passes to ftplib
 File "C:\PYTHON24\lib\ftplib.py", line 345, in transfercmd
   return self.ntransfercmd(cmd, rest)[0]
 File "C:\PYTHON24\lib\ftplib.py", line 321, in ntransfercmd
   host, port = self.makepasv()
 File "C:\PYTHON24\lib\ftplib.py", line 299, in makepasv
   host, port = parse227(self.sendcmd('PASV'))
 File "C:\PYTHON24\lib\ftplib.py", line 566, in parse227
   raise error_reply, resp
error_reply: 200 TYPE is now 8-bit binary   <*** 'is now' indicates 
something has changed resulting in an inconsistency

Line 566 in PYTHON24/lib/ftplib.py:

def parse227(resp):
   '''Parse the '227' response for a PASV request.
   Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'
   Return ('host.addr.as.numbers', port#) tuple.'''
   if resp[:3] != '227':
       raise error_reply, resp     *** Line 566
   global _227_re

Is 'resp' supposed to be an int (227) rather than a string ('227')? 
Probably a wrong conclusion. In version 2.5 it is still a string. 
Anyway, I can't start editing the library trial-and-error style. So, I 
do thank you for the push. Mores pushes will be greatly appreciated, but 
I hesitate to invite travel companions for a stroll into this wilderness.


More information about the Python-list mailing list