def run_cell(self, cell):
    msg_id = self.kc.execute(cell.source)
    self.log.debug('Executing cell:\n%s', cell.source)
    while True:
        try:
            msg = self.kc.shell_channel.get_msg(timeout=self.timeout)
        except Empty:
            self.log.error(('Timeout waiting for execute reply (%is).\n                If your cell should take longer than this, you can increase the timeout with:\n\n                    c.ExecutePreprocessor.timeout = SECONDS\n\n                in jupyter_nbconvert_config.py\n                ' % self.timeout))
            if self.interrupt_on_timeout:
                self.log.error('Interrupting kernel')
                self.km.interrupt_kernel()
                break
            else:
                try:
                    exception = TimeoutError
                except NameError:
                    exception = RuntimeError
                raise exception('Cell execution timed out, see log for details.')
        if (msg['parent_header'].get('msg_id') == msg_id):
            break
        else:
            continue
    outs = []
    while True:
        try:
            msg = self.kc.iopub_channel.get_msg(timeout=self.timeout)
        except Empty:
            self.log.warn('Timeout waiting for IOPub output')
            break
        if (msg['parent_header'].get('msg_id') != msg_id):
            continue
        msg_type = msg['msg_type']
        self.log.debug('output: %s', msg_type)
        content = msg['content']
        if ('execution_count' in content):
            cell['execution_count'] = content['execution_count']
        if (msg_type == 'status'):
            if (content['execution_state'] == 'idle'):
                break
            else:
                continue
        elif (msg_type == 'execute_input'):
            continue
        elif (msg_type == 'clear_output'):
            outs = []
            continue
        elif msg_type.startswith('comm'):
            continue
        try:
            out = output_from_msg(msg)
        except ValueError:
            self.log.error(('unhandled iopub msg: ' + msg_type))
        else:
            outs.append(out)
    return outs
def run_cell(self, cell):
    msg_id = self.kc.execute(cell.source)
    self.log.debug('Executing cell:\n%s', cell.source)
    while True:
        try:
            msg = self.kc.shell_channel.get_msg(timeout=self.timeout)
        except Empty:
            self.log.error(('Timeout waiting for execute reply (%is).\n                If your cell should take longer than this, you can increase the timeout with:\n\n                    c.ExecutePreprocessor.timeout = SECONDS\n\n                in jupyter_nbconvert_config.py\n                ' % self.timeout))
            if self.interrupt_on_timeout:
                self.log.error('Interrupting kernel')
                self.km.interrupt_kernel()
                break
            else:
                try:
                    exception = TimeoutError
                except NameError:
                    exception = RuntimeError
                raise exception('Cell execution timed out, see log for details.')
        if (msg['parent_header'].get('msg_id') == msg_id):
            break
        else:
            continue
    outs = []
    while True:
        try:
            msg = self.kc.iopub_channel.get_msg(timeout=self.timeout)
        except Empty:
            self.log.warn('Timeout waiting for IOPub output')
            break
        if (msg['parent_header'].get('msg_id') != msg_id):
            continue
        msg_type = msg['msg_type']
        self.log.debug('output: %s', msg_type)
        content = msg['content']
        if ('execution_count' in content):
            cell['execution_count'] = content['execution_count']
        if (msg_type == 'status'):
            if (content['execution_state'] == 'idle'):
                break
            else:
                continue
        elif (msg_type == 'execute_input'):
            continue
        elif (msg_type == 'clear_output'):
            outs = []
            continue
        elif msg_type.startswith('comm'):
            continue
        try:
            out = output_from_msg(msg)
        except ValueError:
            self.log.error(('unhandled iopub msg: ' + msg_type))
        else:
            outs.append(out)
    return outs