def close(self):
        """
        Disconnect and error-out all requests.
        """
        with self.lock:
            if self.is_closed:
                return
            self.is_closed = True

        log.debug("Closing connection (%s) to %s", id(self), self.endpoint)
        reactor.callFromThread(self.connector.disconnect)
        log.debug("Closed socket to %s", self.endpoint)

        if not self.is_defunct:
            self.error_all_requests(
                ConnectionShutdown("Connection to %s was closed" % self.endpoint))
            # don't leave in-progress operations hanging
            self.connected_event.set()
def close ( self ) : with self . lock : if self . is_closed : return self . is_closed = True log . debug ( "Closing connection (%s) to %s" , id ( self ) , self . endpoint ) reactor . callFromThread ( self . connector . disconnect ) log . debug ( "Closed socket to %s" , self . endpoint ) if not self . is_defunct : self . error_all_requests ( ConnectionShutdown ( "Connection to %s was closed" % self . endpoint ) ) self . connected_event . set ( )
Disconnect and error-out all requests.