def _drive_coroutine(gen, values):
  """Iterates through a coroutine while feeding it values."""
  next(gen)
  for value in values:
    try:
      gen.send(value)
    except StopIteration as e:
      return e.value