Ignore:
Timestamp:
Oct 12, 2013, 2:29:08 PM (6 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Removed unused `compat.input`.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

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