Hello, everyone. Recently, we have been using multiprocessing to deal with problems. The approximate code is as follows:
def work(i):
-sharp
print("child success")
pass
def throw_error(e):
raise e
def main():
pool = multiprocessing.Pool(processes=10)
for i in range(0,5000):
pool.apply_async(work, (i,), error_callback=throw_error)
pool.close()
pool.join()
print("success")
pass
when this code is running, if there is an exception in the child process, it will be caught and thrown by the main process, and the whole process will not continue to run but will not end, so it needs to be forced to end on the command line ctl+c. I would like to ask if the main process catches a child process exception and the whole process ends directly, how should the code part be modified?