[Pythonmac-SIG] ftplib.storbinary problem
Doug Wyatt
doug@sonosphere.com
Sun, 23 Aug 1998 20:00:30 -0400
Hi all,
Here's another problem that has come up in my switch from Python 1.5a2 to
1.5.1.
I'm using ftplib.storbinary to transfer a file to a server. I'm using a
16K blocksize. The file I'm transferring is 364494 bytes in size, but the
server is only receiving 360448 bytes. 360448 is a multiple of 16K.
I tweaked ftplib.storbinary to show its progress...
def storbinary(self, cmd, fp, blocksize):
'''Store a file in binary mode.'''
self.voidcmd('TYPE I')
conn = self.transfercmd(cmd)
totalSize = 0
while 1:
buf = fp.read(blocksize)
if not buf: break
conn.send(buf)
l = len(buf)
totalSize = totalSize + l
print l
conn.close()
print 'totalSize=',totalSize
return self.voidresp()
It looks like conn.send() might now be asynchronous and thus conn.close()
is getting called before the transfer is complete? I don't know how else
to explain this.
[10 minutes later]
Indeed, yes, if I change it to:
conn.send(buf, socket.MSG_WAITALL) # WAITALL - dsw
it works!!!
Am I reporting this to the right place?
Doug
--
Doug Wyatt doug@sonosphere.com
Sonosphere (electric/improv music) http://www.sonosphere.com/
"Accidental Beauties" CD release: http://www.sonosphere.com/wyatt/
available from CMC, 1-800-882-4262 http://www.MusicDiscoveries.com/