how to retry ftp.new ?

Intermitently, we caught the 'No route to host' exception thrown by FTP.new with these lines of codes. I wonder if rety would help continue the work.