anycall/connectionpool.py
def close(self):
        """
        Stop listing for new connections and close all open connections.
        
        :returns: Deferred that calls back once everything is closed.
        """
        
        def cancel_sends(_):
            logger.debug("Closed port. Cancelling all on-going send operations...")
            while self._ongoing_sends:
                d = self._ongoing_sends.pop()
                d.cancel()

        def close_connections(_):
            all_connections = [c for conns in self._connections.itervalues() for c in conns]
            
            logger.debug("Closing all connections (there are %s)..." % len(all_connections))
            for c in all_connections:
                c.transport.loseConnection()
            ds = [c.wait_for_close() for c in all_connections]
            d = defer.DeferredList(ds, fireOnOneErrback=True)
            
            def allclosed(_):
                logger.debug("All connections closed.")
            d.addCallback(allclosed)
            return d
        
        logger.debug("Closing connection pool...")
        
        d = defer.maybeDeferred(self._listeningport.stopListening)
        d.addCallback(cancel_sends)
        d.addCallback(close_connections)
        return d
def close(self):
        """
        Stop listing for new connections and close all open connections.
        
        :returns: Deferred that calls back once everything is closed.
        """
        
        def cancel_sends(_):
            logger.debug("Closed port. Cancelling all on-going send operations...")
            while self._ongoing_sends:
                d = self._ongoing_sends.pop()
                d.cancel()

        def close_connections(_):
            all_connections = [c for conns in self._connections.itervalues() for c in conns]
            
            logger.debug("Closing all connections (there are %s)..." % len(all_connections))
            for c in all_connections:
                c.transport.loseConnection()
            ds = [c.wait_for_close() for c in all_connections]
            d = defer.DeferredList(ds, fireOnOneErrback=True)
            
            def allclosed(_):
                logger.debug("All connections closed.")
            d.addCallback(allclosed)
            return d
        
        logger.debug("Closing connection pool...")
        
        d = defer.maybeDeferred(self._listeningport.stopListening)
        d.addCallback(cancel_sends)
        d.addCallback(close_connections)
        return d
def close ( self ) : def cancel_sends ( _ ) : logger . debug ( "Closed port. Cancelling all on-going send operations..." ) while self . _ongoing_sends : d = self . _ongoing_sends . pop ( ) d . cancel ( ) def close_connections ( _ ) : all_connections = [ c for conns in self . _connections . itervalues ( ) for c in conns ] logger . debug ( "Closing all connections (there are %s)..." % len ( all_connections ) ) for c in all_connections : c . transport . loseConnection ( ) ds = [ c . wait_for_close ( ) for c in all_connections ] d = defer . DeferredList ( ds , fireOnOneErrback = True ) def allclosed ( _ ) : logger . debug ( "All connections closed." ) d . addCallback ( allclosed ) return d logger . debug ( "Closing connection pool..." ) d = defer . maybeDeferred ( self . _listeningport . stopListening ) d . addCallback ( cancel_sends ) d . addCallback ( close_connections ) return d
Stop listing for new connections and close all open connections.
        
        :returns: Deferred that calls back once everything is closed.
Stop listing for new connections and close all open connections . : returns : Deferred that calls back once everything is closed .