0

the process i'm trying to run doesn't stop until told to, but the data it outputs without finishing are important for me. I'm trying to find a way to read the output constantly, while the process is running. Is it possible to input data too using another function? Example:

def Process():
    def read_data(output):
         if output == 'Ping':
         # input 'pong' to the process
    # run process and assign to variable
    read_data(output_variable)
  • Use `subprocess.Popen()`. – Barmar Sep 20 '21 at 19:57
  • It may be operating system dependent. A unix like OS will let you open a pseudo-terminal (pty). That may turn the program being run into a line buffered pipe instead of a block pipe. – tdelaney Sep 20 '21 at 19:59

0 Answers0