from multiprocessing.pool import ThreadPool pool = ThreadPool(10) def gen(): yield 1 + '1' # here is an error try: next((pool.imap(str, gen()))) except: # Will be catched using pool.map normally, but using pool.imap will be not. # Instead it hangs. This is the same for ThreadPool and Pool. print('this will not be printed because thread is hanging')