docs: def _request(self, msg_type, msg_data=None):
      """Helper function to wrap msg w/ msg_type."""
      msg = {}
      msg['type'] = msg_type
      if msg_data:
        msg['data'] = msg_data
  
      done = False
      tries = 0
      while not done and tries < MAX_RETRIES:
        try:
          MessageSocket.send(self, self.sock, msg)
          done = True
        except socket.error as e:
          tries += 1
          if tries >= MAX_RETRIES:
            raise
          print("Socket error: {}".format(e))
          self.sock.close()
          self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.sock.connect(self.server_addr)
  
      logging.debug("sent: {0}".format(msg))
      resp = MessageSocket.receive(self, self.sock)
      logging.debug("received: {0}".format(resp))
      return resp