def populateBuffer(self, targetIndex):
      """Ensures that all required values are in the buffer"""
      while self.buffer_end < targetIndex:
          try:
              nextValue = self.generator.next()
          except StopIteration:
              self.eof = True
              raise EndOfStreamException()
          self.buffer.append(nextValue)
          self.buffer_end += 1
Ensures that all required values are in the buffer
recipes/Python/392150_Buffered_Stream_Multiple_ForwardOnly/recipe-392150.py