Ignore:
Timestamp:
Oct 8, 2017, 8:00:38 PM (2 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Handle socket read timeout in `_available_child`

When `FTPFile.close` causes a socket read timeout, the _next_ read on
the socket will raise an `OSError`. Hence, the `OSError` can happen in
the `host._session.pwd` call in `FTPHost._available_child`. Catch this
`OSError`.

Although the fix in `ftputil.host.FTPHost._available_child` will make
the child session handling work, socket read errors could result in
child sessions being returned in a non-reproducible way. To make the
identity checks in the tests reproducible, use the small `CONTENTS`
file instead of the larger `debian-keyring.tar.gz` file. Investigation
of ticket #112 showed that socket read errors would rather occur with
larger files.

This change in the tests is slightly hackish, but should be ok, unless
it'll cause other problems later on.

ticket: 112
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1636 r1671  
    175175                # when `_available_child` is called the next time.
    176176                except ftplib.error_reply:
     177                    continue
     178                # Under high load, there may be a socket read timeout
     179                # during the last FTP file `close` (see ticket #112).
     180                except OSError:
    177181                    continue
    178182                else:
Note: See TracChangeset for help on using the changeset viewer.