[issue9400] multiprocessing.pool.AsyncResult.get() messes up exceptions

Ray.Allen report at bugs.python.org
Sun Aug 1 16:04:35 CEST 2010


Ray.Allen <ysj.ray at gmail.com> added the comment:

This is because when an subprocess.CalledProcessError is raised, the CalledProcessError instance is picked through a socket and then read by "parent" process, but in fact CalledProcessError instances cannot be picked correctly. Because CalledProcessError extends PyExc_BaseException, which defines a __reduce__ method, that special method cause the pickle load to call the exception type's __init__ method with packed self.args as arguments. So if a subclass of "Exception" needs to behave correctly in pickling, it should make self.args meats its __init__ method's function signature. That is, ensure the calling to:
          self.__init__(*self.args)
has no problem. 

But CalledProcessError doesn't meat this requirement. Here is a patch fixing the CalledProcessError.__init__ to call its base class's __init__ to store its arguments in self.args, which can fix this bug.

----------
keywords: +patch
Added file: http://bugs.python.org/file18309/issue9400.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9400>
_______________________________________


More information about the Python-bugs-list mailing list