code: def send_message(self, stream, msg):
          
          assert get_thread_ident() == self.ioloop_thread_id
          try:
              if stream.KATCPServer_closing:
                  raise RuntimeError('Stream is closing so we cannot '
                                     'accept any more writes')
              return stream.write(str(msg) + '\n')
          except Exception:
              addr = self.get_address(stream)
              self._logger.warn('Could not send message {0!r} to {1}'
                                .format(str(msg), addr), exc_info=True)
              stream.close(exc_info=True)
docs: Send an arbitrary message to a particular client.
  
          Parameters
          ----------
          stream : :class:`tornado.iostream.IOStream` object
              The stream to send the message to.
          msg : Message object
              The message to send.
  
          Notes
          -----
          This method can only be called in the IOLoop thread.
  
          Failed sends disconnect the client connection and calls the device
          on_client_disconnect() method. They do not raise exceptions, but they
          are logged. Sends also fail if more than self.MAX_WRITE_BUFFER_SIZE
          bytes are queued for sending, implying that client is falling behind.