Once it raises StopIteration, it must continue to do so on subsequent calls to next().
self.results = gevent.queue.Queue()
self.count = 0
self.any_spawned = False
+ self.iteration_stopped = False
def spawn(self, func, *args, **kwargs):
self.count += 1
return self
def next(self):
- if not self.any_spawned:
+ if not self.any_spawned or self.iteration_stopped:
raise StopIteration()
result = self.results.get()
if isinstance(result, BaseException):
+ if isinstance(result, StopIteration):
+ self.iteration_stopped = True
raise result
return result