Traceback when using multiprocessing, less than helpful?

John Ladasky john_ladasky at sbcglobal.net
Thu Nov 21 16:19:56 EST 2013


On Thursday, November 21, 2013 12:53:07 PM UTC-8, Chris Angelico wrote:

> What you could try is 

Suggestion 1:

> printing out the __cause__ and __context__ of 
> the exception, to see if there's anything useful in them; 

Suggestion 2:

> if there's
> nothing, the next thing to try would be some kind of wrapper in your
> inner handler (the evaluate function) that retains additional
> information.

Suggestion 3:

> Oh, something else to try: It might be that the proper exception
> chaining would happen, except that the info isn't traversing processes
> properly due to pickling or something. Can you patch your code to use
> threading instead of multiprocessing? That might reveal something.
> (Don't worry about abysmal performance at this stage.)

I have tried the first suggestion, at the top level of my code.  Here are the modified lines, and the output:

==============================================

try:
    out = evaluate(net, domain)
except ValueError as e:
    print(type(e))
    print(e) # this just produces the exception string itself
    print(e.__context__)
    print(e.__cause__)
    raise e # just so my program actually stops

==============================================

<class 'ValueError'>
operands could not be broadcast together with shapes (1,3) (4) 
None
None

==============================================

So, once I catch the exception, both __context__ and __cause__ are undefined.

I will proceed as you have suggested -- but if anything comes to mind based on what I have already done, please feel free to chime in!



More information about the Python-list mailing list