class TextReader2(object): def __init__(self): self._console = Console() self._command_processor = CommandProcessor(on_exit_method=self._on_stop) self._stop = False def start(self): self._console.start_input_reader(self._on_command) while not self._stop: time.sleep(0.02) def stop(self): self._stop = True def _on_command(self, command): if len(command.strip()) == 0: return self._command_processor.process(command) def _on_stop(self): self.stop()
def __init__(self): self._console = Console() self._command_processor = CommandProcessor(on_exit_method=self._on_stop) self._stop = False