Ftplib Python: Noop Command Works In Ascii Not Binary
I have a threaded FTP script. While the data socket is receiving the data, a threaded loop sends NOOP commands to the control socket to keep control connection alive during large
Solution 1:
tcpdump
confirms that server only sends 226 Transfer complete.
after entire file was sent by the server.
I suspect that's part of FTP specification.
In fact, look at retrbinary
code in ftplib.py
:
self.voidcmd('TYPE I')
conn = self.transfercmd(cmd, rest)
while1:
data = conn.recv(blocksize)
if not data:
break
callback(data)
conn.close()
return self.voidresp()
The last line expects to get tranfer result (as known to server) only after tranfer is complete.
In fact it seems your code is missing voidresp()
bit.
I am not very familiar with ftp, from what I've seen background downloaders like lftp
actually open new control connection for each parallel download.
You have a valid concern if your file is really large.
There are many extensions to FTP, there may be something that does what you want.
Alternatively you can make a loop likes this:
pos = 0whilenot full file:
command REST
download for a while in separate thread
command ABRT
waitfor separate thread to abort
pos += length of downloaded chunk
Post a Comment for "Ftplib Python: Noop Command Works In Ascii Not Binary"