title: PySerial: how to understand that the timeout occured while reading from serial port?
body: <p>I'm using <code>PySerial</code> to read from serial port like in the code below.
  <code>CheckReadUntil()</code> read output of the command that I send to serial port until the sequence of symbols <code>readUntil</code> are in the serial output. </p>
  
  <pre><code>...
  
  self.ser = serial.Serial(comDev, 115200, timeout=10)
  
  ...
  
  #Function that continue to read from Serial port until 'readUntil' 
  #sequence of symbols appears
  def CheckReadUntil(self, readUntil):
      outputCharacters = []
      while 1:
          ch = self.ser.read()
          outputCharacters += ch
          if outputCharacters[-len(readUntil):]==readUntil:
              break
      outputLines = ''.join(outputCharacters)
      return outputLines
  </code></pre>
  
  <p>However, if there is no sequence <code>readUntil</code> (for any reason), I'm just stuck in the function <code>CheckReadUntil()</code> forever. The setting <code>timeout=10</code> sets up timeout so I'm stuck in a loop that iterates every 10 seconds and does nothing, just waiting.</p>
  
  <p>How it is possible to understand that there was a timeout event so I may exit the infinite loop? Output length may be different.</p>