ftplib.FTP.retrbinary() hangs on completion

aum aum at spam.me.please
Thu Jun 29 06:49:21 EDT 2006


Hi,

I've been having some headaches with FTP.retrbinary() hanging on
completion.

I'm only seeing the symptom when downloading a 700k .bmp file in passive
mode.

What happens is that after all the data comes in over the data connection,
.retrbinary() does 'return self.voidresp()'. This has a call chain ending
with 'self.file.readline()'.

To investigate, I overrode the .getline() method with one
which replaces the self.file.readline() with a self.sock.recv(1) loop, and
determined from this that after the last byte of binary data comes in on
the data connection, not a single byte comes in on the control connection.

Not sure if this is a deeper underlying socket issue - I'm running
python2.3 on debian unstable linux.

For a workaround, I've overridden retrbinary, so that it sets a socket
timeout on the control connection prior to doing the last .voidresp()
call, and in the event of timeout, it closes the control connection,
reconnects and logs in again - very ugly.

Can anyone share some light, or offer a better workaround?

-- 

Cheers
aum





More information about the Python-list mailing list