def closeCachedConnections(self):
        """
        Close all persistent connections and remove them from the pool.

        @return: L{defer.Deferred} that fires when all connections have been
            closed.
        """
        results = []
        for protocols in itervalues(self._connections):
            for p in protocols:
                results.append(p.abort())
        self._connections = {}
        for dc in itervalues(self._timeouts):
            dc.cancel()
        self._timeouts = {}
        return defer.gatherResults(results).addCallback(lambda ign: None)

        Close all persistent connections and remove them from the pool.

        @return: L{defer.Deferred} that fires when all connections have been
            closed.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/client.py