Why no errors from multiprocessing is reported in Python and how to switch on reporting errors?

落爺英雄遲暮 提交于 2019-12-08 08:49:31

You can try, catch, and log exceptions that occur inside your worker processes. Something like this

def worker(io_lock, value):
    try:
        raise RuntimeError('URGH') # Or do your actual work here
    except:
        logging.exception('Exception occurred: ')
        raise  # Re-raise the exception so that the process exits 

The exception log handler will automatically include the stacktrace.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!