[python-win32] regarding ftp api call

Tim Golden mail at timgolden.me.uk
Wed Sep 23 12:18:47 CEST 2009


a h wrote:
> Hi all
> i have created an ftp client using ftp api provided in python. whenever i
> disconnect my ftp client with the ftp server by removing the wired
> connection, my ftp application get hanged, i traced with prints and find
> that whenever call made to ftp api, it never came back. How do i
> resolve this as it does not return any error or value.
> Plz help, thanks in advance

It always helps if you provide some sort of code sample which
shows the problem (or at least, where the problem occurs). But
I would imagine that you've got an open socket with no timeout.
As a quick workaround, try adding this before your FTP code:

<code>

import socket
socket.setdefaulttimeout (1.0)

</code>

which will cause a socket to time out in 1 second. You'll then have
to catch whatever exception it raises and do something meaningful
within the context of your code.

TJG


More information about the python-win32 mailing list