def __raw_message_handler(self, raw_message):
    match = self.raw_message_regexp.match(raw_message)
    if match:
        [message_id, message_body] = (int(match.group(1)), match.group(2))
        message_body = raw_message[(len(match.group(1)) + 1):]
        try:
            message_body = message_body.decode('utf-8')
        except UnicodeDecodeError:
            pass
        if (message_id == self.message_id):
            self.response = message_body
            self.wait_response.set()
        else:
            assert False
    elif self.message_handler:

        def do_callback():
            self.message_handler(raw_message)
        self.queue.put(do_callback)
    else:
        _L.error('No message handler to handle message %s', raw_message)
def __raw_message_handler(self, raw_message):
    match = self.raw_message_regexp.match(raw_message)
    if match:
        [message_id, message_body] = (int(match.group(1)), match.group(2))
        message_body = raw_message[(len(match.group(1)) + 1):]
        try:
            message_body = message_body.decode('utf-8')
        except UnicodeDecodeError:
            pass
        if (message_id == self.message_id):
            self.response = message_body
            self.wait_response.set()
        else:
            assert False
    elif self.message_handler:

        def do_callback():
            self.message_handler(raw_message)
        self.queue.put(do_callback)
    else:
        _L.error('No message handler to handle message %s', raw_message)