code: def _cleanup(self):
          
          for channel in self._open_channels:
              try:
                  self.disconnect_channel(channel)
              except Exception:  # pylint: disable=broad-except
                  pass
  
          for handler in self._handlers.values():
              try:
                  handler.tear_down()
              except Exception:  # pylint: disable=broad-except
                  pass
  
          try:
              self.socket.close()
          except Exception:  # pylint: disable=broad-except
              self.logger.exception(
                  "[%s:%s] _cleanup", self.fn or self.host, self.port)
          self._report_connection_status(
              ConnectionStatus(CONNECTION_STATUS_DISCONNECTED,
                               NetworkAddress(self.host, self.port)))
          self.connecting = True
docs: Cleanup open channels and handlers