code: def test_stream_popen2():
      script = """for i in 0 1 2 3 4 5
  do
      echo "This messages goes to stdout $i"
      sleep 1
      echo This message goes to stderr >&2
      sleep 1
  done
  """
      with open("pieces.sh", "wt") as f:
          f.write(script)
      with sp.Popen(
          ["./pieces.sh"],
          stdout=sp.PIPE,
          stderr=sp.PIPE,
          text=True,
          shell=True,
      ) as p:
          for out_line, err_line in read_popen_pipes(p):
              print(out_line, end="")
              print(err_line, end="")
          p.poll()
  
file_path: h2ogpt/tests/test_utils.py
imports: import sys
  import pytest
  from src.utils import get_list_or_str, read_popen_pipes, get_token_count, reverse_ucurve_list, undo_reverse_ucurve_list
  from tests.utils import wrap_test_forked
  import subprocess
label_desc: Use image node_id 3 for calling a global function with example usage: test_stream_popen2() without return types