ftplib.FTP.retrbinary() hangs on completion

A

aum

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?
 
F

Fredrik Lundh

aum said:
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.

since both sides has closed the data connection socket when you get that far, it
looks like the server you're talking to is broken; see

http://cr.yp.to/ftp/retr.html

for details on what the server is supposed to do, and what the client can expect
from the server.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top