I'm trying to download a file from FTP server which is about 100 MB. It's a test .bin file because I'm testing the app and I guess the files I will want to download in the future will weight even more. When I want to download the file the whole application just freezes and then after a few seconds it downloads the file. The file is complete and it downloads it successfully without any errors or something like that. The only problem is the freeze.
My code:
ftp = FTP('exampledomain.com')
ftp.login(user='user', passwd='password')
ftp.cwd('/main_directory/')
filename = '100MB.bin'
with open(filename, 'wb') as localfile:
ftp.retrbinary('RETR ' + filename, localfile.write, 1024)
ftp.quit()
localfile.close()
I tried using sleep()
between some lines of the code e.g between the logging in and downloading the file but it didn't help and it also seems that sleep()
does not work AT ALL when working with FTP.