FTP not Returning (Python on Series 60 Nokia)

Fredrik Lundh fredrik at pythonware.com
Wed Mar 29 09:51:30 CEST 2006

mbukhin at gmail.com wrote:

> I'm using the ftp library (layer on top of sockets) to transfer files
> from  a series 60 to an ftp site.  everything works fine, the whole
> file gets uploaded but the command never returns!  so
> i call:
> ftp.storbinary('STOR ' + filename,F,1024) # store the image
> which does this:
>      def storbinary(self, cmd, fp, blocksize=8192):
>          '''Store a file in binary mode.'''
>          self.voidcmd('TYPE I')
>          conn = self.transfercmd(cmd)
>          while 1:
>              buf = fp.read(blocksize)
>              if not buf: break
>              conn.send(buf)
>          conn.close()
>          return self.voidresp()
> and the 'while 1' never stops.  That's my guess anyway.

assuming that the connection works properly, the only way to get stuck
in the while loop is if the size of your file is infinitely huge.

so it's probably a connection issue; I suggest adding print statements
around the conn.send and conn.close calls, to make it easier to see
where you get stuck.

setting the debug level (e.g. ftp.set_debuglevel(2)) might also provide
some additional clues.


More information about the Python-list mailing list