code: def expect_async(expecter, timeout=None):
      # First process data that was previously read - if it maches, we don't need
      # async stuff.
      idx = expecter.existing_data()
      if idx is not None:
          return idx
      if not expecter.spawn.async_pw_transport:
          pw = PatternWaiter()
          pw.set_expecter(expecter)
          (
              transport,
              pw,
          ) = yield from asyncio.get_event_loop().connect_read_pipe(
              lambda: pw, expecter.spawn
          )
          expecter.spawn.async_pw_transport = pw, transport
      else:
          pw, transport = expecter.spawn.async_pw_transport
          pw.set_expecter(expecter)
          transport.resume_reading()
      try:
          return (yield from asyncio.wait_for(pw.fut, timeout))
      except asyncio.TimeoutError as e:
          transport.pause_reading()
          return expecter.timeout(e)
  
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 1 for calling a global function with example usage: expect_async(expecter, timeout) and returns: idx, unknown, expecter