<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_message(self, stream, timeout=None):
 """ Function is used to get a message from the iopub channel. Timeout is None by default When timeout is reached """

        try:
            if stream == 'iopub':
                msg = self.kc.get_iopub_msg(timeout=timeout)
            elif stream == 'shell':
                msg = self.kc.get_shell_msg(timeout=timeout)
            else:
                raise ValueError('Invalid stream specified: "%s"' % stream)
        except Empty:
            logger.debug('Kernel: Timeout waiting for message on %s', stream)
            raise
        logger.debug("Kernel message (%s):\n%s", stream, pformat(msg))
        return msg