code: def _message(self, bus, message):
          
          if not self.finished:
              if message.type == Gst.MessageType.EOS:
                  # The file is done. Tell the consumer thread.
                  self.queue.put(SENTINEL)
                  if not self.got_caps:
                      # If the stream ends before _notify_caps was called, this
                      # is an invalid file.
                      self.read_exc = NoStreamError()
                      self.ready_sem.release()
  
              elif message.type == Gst.MessageType.ERROR:
                  gerror, debug = message.parse_error()
                  if 'not-linked' in debug:
                      self.read_exc = NoStreamError()
                  elif 'No such file' in debug:
                      self.read_exc = IOError('resource not found')
                  else:
                      self.read_exc = FileReadError(debug)
                  self.ready_sem.release()
docs: The callback for GstBus's "message" signal (for two kinds of
          messages).