def start_command(self, command, prompt, input_end_mark_str, output_end_mark_str, input_start_first = False): if (input_start_first == True): self.show_prompt = True self.command_pipe = Popen(command, stdin = PIPE, stdout = PIPE, stderr = PIPE, bufsize = 1) queue = Queue() queue.closed = False thread_stdout_queue = Thread(target = self.enqueue_output, args = (queue, self.command_pipe.stdout)) thread_stdout_queue.daemon = True thread_stdout_queue.start() thread_stderr_queue = Thread(target = self.enqueue_output, args = (queue, self.command_pipe.stderr)) thread_stderr_queue.daemon = True thread_stderr_queue.start() thread_input = Thread(target = self.catch_input, args = (self.command_pipe, queue, input_end_mark_str, input_start_first)) thread_input.start() thread_output = Thread(target = self.catch_output, args = (self.command_pipe, queue, prompt, output_end_mark_str)) thread_output.start()