From f9daa702594bb73cab83b7d6df02c0f11a835a35 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Wed, 31 Aug 2011 17:13:06 -0700 Subject: [PATCH] parallel: don't hang if no tasks were spawned This makes 6d919152178cfbd69dc5d50cdab40fc99db166a6 work. --- teuthology/parallel.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/teuthology/parallel.py b/teuthology/parallel.py index d8215a9e55..c3463a0408 100644 --- a/teuthology/parallel.py +++ b/teuthology/parallel.py @@ -35,9 +35,11 @@ class parallel(object): self.group = gevent.pool.Group() self.results = gevent.queue.Queue() self.count = 0 + self.any_spawned = False def spawn(self, func, *args, **kwargs): self.count += 1 + self.any_spawned = True greenlet = self.group.spawn(func, *args, **kwargs) greenlet.link(self._finish) @@ -63,6 +65,8 @@ class parallel(object): return self def next(self): + if not self.any_spawned: + raise StopIteration() result = self.results.get() if isinstance(result, BaseException): raise result -- 2.39.5