1

I am new in python and have query. I am providing error_callback for multiprocessing pool. An exception is thrown inside thread. Thread has try..except handler and it raises exception. That exception is when reraised inside error_callback causes hang in program, whereas if it is not reraised in error_callback works fine. I want to know underlying cause.

try:
    result = pool.apply_async(func,error_callback=log_error)  # func raises exception
    result.get()
    pool.close()
except Exception as e:
    pool.terminate()
finally:
    pool.join()

def log_error(error):
    raise Exception(error)  # This causes hangs while

def log_error(error):
    print(error)  # works fine
bereal
  • 32,519
  • 6
  • 58
  • 104
  • Similar Q here: https://stackoverflow.com/questions/19924104/python-multiprocessing-handling-child-errors-in-parent – Amiga500 Apr 12 '21 at 12:09

0 Answers0