<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send_message(self, message, channel):
 """ Internal. Sends the actual message from a queue entry. """

        if not self.is_connected(channel):
            return False

        message['_sending'] = True

        if '_data' in message:
            data = message['_data']
        else:
            data = msgpack.packb(message, default=invalid_json_values)
            self.bytes_total += len(data)
            message['_bytes_sent'] = 0
            message['_id'] = -1

        if is_debug2():
            sys.__stderr__.write("[%s] send message: %s\n" % (channel, str(msgpack.unpackb(data))[0:180]))

        try:
            while data:
                start = time.time()
                bytes_sent = self.ssh_channel[channel].send(data)

                data = data[bytes_sent:]
                message['_bytes_sent'] += bytes_sent
                self.bytes_sent += bytes_sent

                end = time.time()
                self.write_speeds.append(bytes_sent / (end-start))

                speeds_len = len(self.write_speeds)
                if speeds_len:
                    self.bytes_speed = sum(self.write_speeds) / speeds_len
                    if speeds_len > 10:
                        self.write_speeds = self.write_speeds[5:]

            message['_sent'] = True
            return True

        except (KeyboardInterrupt, SystemExit):
            if message['_sent']:
                return message['_bytes_sent']

            return False

        except Exception as error:
            self.connection_error(channel, error)
            return False