class_docstr: Telnet interface class.
  
  An instance of this class represents a connection to a telnet
  server.  The instance is initially not connected; the open()
  method must be used to establish a connection.  Alternatively, the
  host name and optional port number can be passed to the
  constructor, too.
  
  Don't try to reopen an already connected instance.
  
  This class has many read_*() methods.  Note that some of them
  raise EOFError when the end of the connection is read, because
  they can return an empty string for other reasons.  See the
  individual doc strings.
  
  read_until(expected, [timeout])
      Read until the expected string has been seen, or a timeout is
      hit (default is no timeout); may block.
  
  read_all()
      Read all data until EOF; may block.
  
  read_some()
      Read at least one byte or EOF; may block.
  
  read_very_eager()
      Read all data available already queued or on the socket,
      without blocking.
  
  read_eager()
      Read either data already queued or some data available on the
      socket, without blocking.
  
  read_lazy()
      Read all data in the raw queue (processing it first), without
      doing any socket I/O.
  
  read_very_lazy()
      Reads all data in the cooked queue, without doing any socket
      I/O.
  
  read_sb_data()
      Reads available data between SB ... SE sequence. Don't block.
  
  set_option_negotiation_callback(callback)
      Each time a telnet option is read on the input flow, this callback
      (if set) is called with the following parameters :
      callback(telnet socket, command, option)
          option will be chr(0) when there is no option.
      No other action is done afterwards by telnetlib.
class_docstr_tok: ["Telnet","interface","class",".","An","instance","of","this","class","represents","a","connection","to","a","telnet","server",".","The","instance","is","initially","not","connected",";","the","open","(",")","method","must","be","used","to","establish","a","connection",".","Alternatively",",","the","host","name","and","optional","port","number","can","be","passed","to","the","constructor",",","too",".","Do","n't","try","to","reopen","an","already","connected","instance",".","This","class","has","many","read_","*","(",")","methods",".","Note","that","some","of","them","raise","EOFError","when","the","end","of","the","connection","is","read",",","because","they","can","return","an","empty","string","for","other","reasons",".","See","the","individual","doc","strings",".","read_until","(","expected",",","[","timeout","]",")","Read","until","the","expected","string","has","been","seen",",","or","a","timeout","is","hit","(","default","is","no","timeout",")",";","may","block",".","read_all","(",")","Read","all","data","until","EOF",";","may","block",".","read_some","(",")","Read","at","least","one","byte","or","EOF",";","may","block",".","read_very_eager","(",")","Read","all","data","available","already","queued","or","on","the","socket",",","without","blocking",".","read_eager","(",")","Read","either","data","already","queued","or","some","data","available","on","the","socket",",","without","blocking",".","read_lazy","(",")","Read","all","data","in","the","raw","queue","(","processing","it","first",")",",","without","doing","any","socket","I\/O",".","read_very_lazy","(",")","Reads","all","data","in","the","cooked","queue",",","without","doing","any","socket","I\/O",".","read_sb_data","(",")","Reads","available","data","between","SB","...","SE","sequence",".","Do","n't","block",".","set_option_negotiation_callback","(","callback",")","Each","time","a","telnet","option","is","read","on","the","input","flow",",","this","callback","(","if","set",")","is","called","with","the","following","parameters",":","callback","(","telnet","socket",",","command",",","option",")","option","will","be","chr","(","0",")","when","there","is","no","option",".","No","other","action","is","done","afterwards","by","telnetlib","."]
docstr: Read until a given string is encountered or until timeout.
  
  When no match is found, return whatever is available instead,
  possibly the empty string.  Raise EOFError if the connection
  is closed and no cooked data is available.
docstr_tok: ["Read","until","a","given","string","is","encountered","or","until","timeout",".","When","no","match","is","found",",","return","whatever","is","available","instead",",","possibly","the","empty","string",".","Raise","EOFError","if","the","connection","is","closed","and","no","cooked","data","is","available","."]
code: def read_until(self, match, timeout=None):
      """Read until a given string is encountered or until timeout.
  
      When no match is found, return whatever is available instead,
      possibly the empty string.  Raise EOFError if the connection
      is closed and no cooked data is available.
  
      """
      n = len(match)
      self.process_rawq()
      i = self.cookedq.find(match)
      if i >= 0:
          i = i + n
          buf = self.cookedq[:i]
          self.cookedq = self.cookedq[i:]
          return buf
      if timeout is not None:
          deadline = _time() + timeout
      with _TelnetSelector() as selector:
          selector.register(self, selectors.EVENT_READ)
          while not self.eof:
              if selector.select(timeout):
                  i = max(0, len(self.cookedq) - n)
                  self.fill_rawq()
                  self.process_rawq()
                  i = self.cookedq.find(match, i)
                  if i >= 0:
                      i = i + n
                      buf = self.cookedq[:i]
                      self.cookedq = self.cookedq[i:]
                      return buf
              if timeout is not None:
                  timeout = deadline - _time()
                  if timeout < 0:
                      break
      return self.read_very_lazy()
  
imports: import sys
  import socket
  import selectors
  from time import monotonic
  import warnings
label_desc: Use image node_id 10 for calling the Telnet obj's underlying member method code with example usage: obj.read_until(match, timeout) and returns: self, buf, buf