[python-win32] regarding ftp api call

Tim Golden mail at timgolden.me.uk
Wed Sep 23 14:04:27 CEST 2009


[copying back to the list]

Please keep the conversation on-list, a h. We're all
happy to help you, but none of us is a private
consultant -- at least not an unpaid one! Also,
the more people who see what you post, the more
people there are who might be able to answer.

a h wrote:
> I have wriiten this piece of code which works fine. which retrieve files
> from server and dumping to the local folder
> 
> import ftplib
> f = ftplib.FTP("server_host_name")
> while True:
>     f.pwd()
>     ...
>     ...my logic
>     f.retrbinary("RETR %s"% fname, myFile.write)
>     ...
> 
> but when disconnected say wire remove then it hang in loop, it does not
> throw any exception or any error. I traced by putting prints, and find that
> it hanged in ftp api call like "f.pwd()  OR f.retrbinary()" and never return
> back


Did you try my suggestion of setting a socket timeout?

TJG


More information about the python-win32 mailing list