Ignore:
Timestamp:
Oct 20, 2013, 8:19:57 PM (6 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Parents:
1449:22d7f6132882 (diff), 1454:8523e3167527 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merged in changes made on warpy.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1449 r1455  
    125125    def _available_child(self):
    126126        """
    127         Return an available (i. e. one whose `_file` object is closed
    128         and doesn't have a timed-out server connection) child
    129         (`FTPHost` object) from the pool of children or `None` if
    130         there aren't any.
    131         """
    132         #TODO: Currently timed-out child sessions aren't removed and
    133         # may collect over time. In very busy or long running
    134         # processes, this might slow down an application because the
    135         # same stale child sessions have to be processed again and
    136         # again.
    137         for host in self._children:
     127        Return an available `FTPHost` child (i. e. one whose
     128        `_file` object is closed and doesn't have a timed-out
     129        server connection) from the pool of children or `None`
     130        if there aren't any.
     131        """
     132        child_indices_to_delete = []
     133        for index, host in enumerate(self._children):
    138134            # Test for timeouts only after testing for a closed file:
    139135            # - If a file isn't closed, save time; don't bother to access
     
    147143                # Timed-out sessions raise `error_temp`.
    148144                except ftplib.error_temp:
     145                    child_indices_to_delete.append(index)
    149146                    continue
    150147                else:
    151148                    # Everything's ok; use this `FTPHost` instance.
    152149                    return host
    153         # Be explicit.
     150        # Remove timed-out children. Work from the end to the start
     151        # of the list so that the previously collected indices remain
     152        # valid while modifying the list in-place.
     153        for index in reversed(child_indices_to_delete):
     154            del self._children[index]
     155        # No available child found.
    154156        return None
    155157
  • ftputil/host.py

    r1454 r1455  
    114114        # `FTPHost` object's child sessions.
    115115        factory = kwargs.pop("session_factory", ftplib.FTP)
    116         # pylint: disable=W0142
    117116        with ftputil.error.ftplib_error_to_ftp_os_error:
    118117            return factory(*args, **kwargs)
     
    267266        """
    268267        # Implicitly set via `set_time_shift` call in constructor
    269         # pylint: disable=W0201
     268        # pylint: disable=attribute-defined-outside-init
    270269        self._time_shift = time_shift
    271270
     
    581580
    582581    # Ignore unused argument `mode`
    583     # pylint: disable=W0613
     582    # pylint: disable=unused-argument
    584583    def mkdir(self, path, mode=None):
    585584        """
     
    596595
    597596    # Ignore unused argument `mode`
    598     # pylint: disable=W0613
     597    # pylint: disable=unused-argument
    599598    def makedirs(self, path, mode=None):
    600599        """
     
    703702            def new_onerror(*args):
    704703                """Do nothing."""
    705                 # Ignore unused arguments
    706                 # pylint: disable=W0613
     704                # pylint: disable=unused-argument
    707705                pass
    708706        elif onerror is None:
    709707            def new_onerror(*args):
    710708                """Re-raise exception."""
    711                 # Ignore unused arguments
    712                 # pylint: disable=W0613
     709                # pylint: disable=unused-argument
    713710                raise
    714711        else:
     
    777774                """Callback function."""
    778775                lines.append(ftputil.tool.as_unicode(line))
    779             # pylint: disable=W0142
    780776            with ftputil.error.ftplib_error_to_ftp_os_error:
    781777                if self.use_list_a_option:
     
    898894    def __exit__(self, exc_type, exc_val, exc_tb):
    899895        # We don't need the `exc_*` arguments here.
    900         # pylint: disable=W0613
     896        # pylint: disable=unused-argument
    901897        self.close()
    902898        # Be explicit.
Note: See TracChangeset for help on using the changeset viewer.