code: def repl_run_command_async(repl, cmdlines, timeout=-1):
      res = []
      repl.child.sendline(cmdlines[0])
      for line in cmdlines[1:]:
          yield from repl._expect_prompt(timeout=timeout, async_=True)
          res.append(repl.child.before)
          repl.child.sendline(line)
  
      # Command was fully submitted, now wait for the next prompt
      prompt_idx = yield from repl._expect_prompt(
          timeout=timeout, async_=True
      )
      if prompt_idx == 1:
          # We got the continuation prompt - command was incomplete
          repl.child.kill(signal.SIGINT)
          yield from repl._expect_prompt(timeout=1, async_=True)
          raise ValueError(
              "Continuation prompt found - input was incomplete:"
          )
      return "".join(res + [repl.child.before])
  
file_path: catboost/contrib/python/pexpect/py3/pexpect/_async_pre_await.py
imports: import asyncio
  import errno
  import signal
  from pexpect import EOF
label_desc: Use image node_id 2 for calling a global function with example usage: repl_run_command_async(repl, cmdlines, timeout) and returns: str