code: def waitfor(self, prompt):
          
          while True:
              try:
                  result = self._waitfor(prompt)
              except DriverReplacedException:
                  continue  # retry
              return result
docs: Monitors the data received from the remote host and waits until
          the response matches the given prompt.
          Once a match has been found, the buffer containing incoming data
          is NOT changed. In other words, consecutive calls to this function
          will always work, e.g.::
  
              conn.waitfor('myprompt>')
              conn.waitfor('myprompt>')
              conn.waitfor('myprompt>')
  
          will always work. Hence in most cases, you probably want to use
          expect() instead.
  
          This method also stores the received data in the response
          attribute (self.response).
  
          Returns the index of the regular expression that matched.
  
          :type  prompt: str|re.RegexObject|list(str|re.RegexObject)
          :param prompt: One or more regular expressions.
          :rtype:  int, re.MatchObject
          :return: The index of the regular expression that matched,
            and the match object.
  
          @raise TimeoutException: raised if the timeout was reached.
  
          @raise ExpectCancelledException: raised when cancel_expect() was
          called in a callback.
  
          @raise ProtocolException: on other internal errors.
  
          @raise Exception: May raise other exceptions that are caused
          within the underlying protocol implementations.