def run(self):
        "Called in a separate thread by Thread.start()."
        queue = self.queue
        try:
            it = iter(self.generator)
            while 1:
                next = it.next()
                queue.put((1, next)) # will raise StopIteration
                if self.stopRequested:
                    raise StopIteration, "stop requested"
        except:
            queue.put((0, sys.exc_info()))
Called in a separate thread by Thread.start().
recipes/Python/196890_Spawned_Generators/recipe-196890.py