'Simulate keyboard interrupt'

def keyboard_interrupt(self):

    if self.multithreaded:
        self.interpreter.raise_keyboard_interrupt()
    elif self.interpreter.more:
        self.write_error('\nKeyboardInterrupt\n')
        self.interpreter.more = False
        self.new_prompt(self.interpreter.p1)
        self.interpreter.resetbuffer()
    else:
        self.interrupted = True
