import threading def getdocs(): while True: yield None class B(object): def doit(self): self.docIter = getdocs() self.docIter.next() print 'exiting generator' class A(object): def run(self): while True: self.func() def func(self): b = B() thread = threading.Thread(target=b.doit) thread.start() try: raise Exception except Exception: thread.join() print 'joined thread' if __name__ == '__main__': a = A() a.run()