Exception thrown in multiprocessing Pool not detected

后端 未结 9 829
灰色年华
灰色年华 2020-11-29 18:44

It seems that when an exception is raised from a multiprocessing.Pool process, there is no stack trace or any other indication that it has failed. Example:

         


        
9条回答
  •  醉酒成梦
    2020-11-29 19:29

    I created a module RemoteException.py that shows the full traceback of a exception in a process. Python2. Download it and add this to your code:

    import RemoteException
    
    @RemoteException.showError
    def go():
        raise Exception('Error!')
    
    if __name__ == '__main__':
        import multiprocessing
        p = multiprocessing.Pool(processes = 1)
        r = p.apply(go) # full traceback is shown here
    

提交回复
热议问题