On May 24, 11:53 am, [EMAIL PROTECTED] wrote: > I am breaking/interrupting my connection with the ftp server at > present when doing a partial download of a file. I have a callback > with retrbinary that raises an exception and ends the download. The > problem is that the server is not notified and hangs. I cannot send > any further commands and need to relogin to download further. Is there > a way to still continue downloading without having to login again. > > My retrbinary function is: > > ftp.retrbinary('RETR '+file, handleDownload,1,bound[0]) > > where bound[0] is an integer specifying the start byte of the > download. > > My callback is: > > def handleDownload(block): > global count,localfile,number > localfile.write(block) > if count==number: > raise(Exception) > count=count+1 > > where number specifies the number of bytes to download. > > Help would be gratefully received.
Have you tried ftp.abort()? The docs say "Abort a file transfer that is in progress. Using this does not always work, but it's worth a try.". I'd also suggest that you download more than 1 byte at a time, perhaps 1024 (fewer if you're on dial-up). -- http://mail.python.org/mailman/listinfo/python-list