Deal with EOFError while downloading files from server
问题 Use Case: Dowload hundred of thousands of xmls files (size from bytes to 50 mb/file) structured like this /year-month/year-month-day/hours/files with ftplib. So i loop through each hour folder for a given day and for each one i store all the filenames with ftp.nlst(), then i loop through each filename and i donwload the concerned file like this. with open(local_file, 'wb') as fhandle: try: ftp.retrbinary('RETR ' + filename, fhandle.write) except EOFError: try: fhandle.close() os.remove(local