ftplib.FTP.retrbinary() hangs on completion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • aum

    #1

    ftplib.FTP.retrbinary() hangs on completion

    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.read line()'.

    To investigate, I overrode the .getline() method with one
    which replaces the self.file.readl ine() 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


  • Fredrik Lundh

    #2
    Re: ftplib.FTP.retr binary() hangs on completion

    "aum" <aum@spam.me.pl ease> wrote:
    [color=blue]
    > 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.read line()'.
    >
    > To investigate, I overrode the .getline() method with one
    > which replaces the self.file.readl ine() 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.[/color]

    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



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

    </F>



    Comment

    Working...