docstr: Blocking expect
docstr_tok: ["Blocking","expect"]
code: def expect_loop(self, timeout=-1):
      """Blocking expect"""
      spawn = self.spawn
  
      if timeout is not None:
          end_time = time.time() + timeout
  
      try:
          idx = self.existing_data()
          if idx is not None:
              return idx
          while True:
              # No match at this point
              if (timeout is not None) and (timeout < 0):
                  return self.timeout()
              # Still have time left, so read more data
              incoming = spawn.read_nonblocking(spawn.maxread, timeout)
              if self.spawn.delayafterread is not None:
                  time.sleep(self.spawn.delayafterread)
              idx = self.new_data(incoming)
              # Keep reading until exception or return.
              if idx is not None:
                  return idx
              if timeout is not None:
                  timeout = end_time - time.time()
      except EOF as e:
          return self.eof(e)
      except TIMEOUT as e:
          return self.timeout(e)
      except:
          self.errored()
          raise
  
imports: import time
  from .exceptions import EOF, TIMEOUT
label_desc: Use image node_id 8 for calling the Expecter obj's underlying member method code with example usage: obj.expect_loop(timeout) and returns: idx, self, self, self, idx