code: def _reader_thread_func(self, read_stdout: bool) -> None:
          
          if read_stdout:
              read_stream = self._proc.stdout
              write_stream = self._stdout
          else:
              read_stream = self._proc.stderr
              write_stream = self._stderr
  
          # The thread should have been started only if this stream was a pipe
          assert read_stream is not None
  
          # Run until process completes
          while self._proc.poll() is None:
              # noinspection PyUnresolvedReferences
              available = read_stream.peek()
              if available:
                  read_stream.read(len(available))
                  self._write_bytes(write_stream, available)
docs: Thread function that reads a stream from the process
          :param read_stdout: if True, then this thread deals with stdout. Otherwise it deals with stderr.