Ignore:
Timestamp:
Feb 18, 2016, 9:35:29 PM (4 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Fix invalid 226 reply bug (ticket 102)

Under FTP server load, a 226 reply from the server may not be "seen"
while a remote file is closed in `FTPFile.close`. If the reply is only
seen in in the `pwd` call in `FTPHost._available_child`, `ftplib`
raises an `error_reply` exception since no 226 is expected from a
`pwd` call.

This changeset fixes the bug by explicitly catching the `error_reply`
exception. This is the same approach as for timed-out child sessions,
which cause an `error_temp` exception.

The fix will cause `_available_child` to ignore the child session
whose `pwd` caused the `error_reply` exception. However, the child
will be tried again next time `_available_child` is called and should
then have a working `pwd` call (unless the child session timed out,
in which case it will cause an `error_temp`).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1633 r1636  
    168168                # Timed-out sessions raise `error_temp`.
    169169                except ftplib.error_temp:
     170                    continue
     171                # Under high load, a 226 status response from a
     172                # previous download may arrive too late, so that it's
     173                # "seen" in the `pwd` call. For now, skip the
     174                # potential child session; it will be considered again
     175                # when `_available_child` is called the next time.
     176                except ftplib.error_reply:
    170177                    continue
    171178                else:
Note: See TracChangeset for help on using the changeset viewer.