Nov 3, 2013, 10:49:52 AM (6 years ago)
Stefan Schwarzer <sschwarzer@…>
Backed out changeset 8523e3167527.

I had accidentally also committed changes to `host.py`. I plan
to use these changes in a future version of ftputil, but not yet
in the next release.
1 edited


  • ftputil/host.py

    r1459 r1465  
    137137    def _available_child(self):
    138138        """
    139         Return an available `FTPHost` child (i. e. one whose
    140         `_file` object is closed and doesn't have a timed-out
    141         server connection) from the pool of children or `None`
    142         if there aren't any.
    143         """
    144         child_indices_to_delete = []
    145         for index, host in enumerate(self._children):
     139        Return an available (i. e. one whose `_file` object is closed
     140        and doesn't have a timed-out server connection) child
     141        (`FTPHost` object) from the pool of children or `None` if
     142        there aren't any.
     143        """
     144        #TODO: Currently timed-out child sessions aren't removed and
     145        # may collect over time. In very busy or long running
     146        # processes, this might slow down an application because the
     147        # same stale child sessions have to be processed again and
     148        # again.
     149        for host in self._children:
    146150            # Test for timeouts only after testing for a closed file:
    147151            # - If a file isn't closed, save time; don't bother to access
    155159                # Timed-out sessions raise `error_temp`.
    156160                except ftplib.error_temp:
    157                     child_indices_to_delete.append(index)
    158161                    continue
    159162                else:
    160163                    # Everything's ok; use this `FTPHost` instance.
    161164                    return host
    162         # Remove timed-out children. Work from the end to the start
    163         # of the list so that the previously collected indices remain
    164         # valid while modifying the list in-place.
    165         for index in reversed(child_indices_to_delete):
    166             del self._children[index]
    167         # No available child found.
     165        # Be explicit.
    168166        return None
Note: See TracChangeset for help on using the changeset viewer.