ftplib retrlines timeout

Brendan brendandetracey at yahoo.com
Wed Dec 16 07:41:17 EST 2009


On Dec 15, 6:17 pm, Jennifer <owenzhang.chic... at gmail.com> wrote:
> I am writing a program that has a requirement for  a timeout of
> retrlines after the connection established. I just wonder if timeout
> of ftplib.FTP('xxxx.xxx.com',username,password,timeout) will work for
> retrlines method after the connection established. Or
> socket.setdefaulttimeout will work in this case. Please let me know.
>
> What exception will be throwed if ftp.retrlines timed out.
>
> Many Thanks!
>
> - Jennifer

I asked a similar question on here a few days ago and got no response,
however I tried a large download which timed out with the following:
Traceback (most recent call last):
  File "./download_r1_neodf.py", line 167, in <module>
    result = ftp.quit()
  File "/usr/local/lib/python2.6/ftplib.py", line 566, in quit
    resp = self.voidcmd('QUIT')
  File "/usr/local/lib/python2.6/ftplib.py", line 248, in voidcmd
    return self.voidresp()
  File "/usr/local/lib/python2.6/ftplib.py", line 223, in voidresp
    resp = self.getresp()
  File "/usr/local/lib/python2.6/ftplib.py", line 209, in getresp
    resp = self.getmultiline()
  File "/usr/local/lib/python2.6/ftplib.py", line 195, in getmultiline
    line = self.getline()
  File "/usr/local/lib/python2.6/ftplib.py", line 182, in getline
    line = self.file.readline()
  File "/usr/local/lib/python2.6/socket.py", line 406, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: [Errno 110] Connection timed out


BTW, if you want to use the timeout paramter, you must also use the
account parameter. Set it to ''.



More information about the Python-list mailing list