Skip to content

Conversation

@danmou
Copy link

@danmou danmou commented Dec 7, 2019

In a multiprocessing scenario, you might want to send and exception through a pipe so it can be logged by the main process. This requires the exception to be pickleable, which is not the case when the exception is raised by a @gin.configurable-decorated function because utils.augment_exception_message_and_reraise creates a proxy class dynamically, which pickle can't access. That leads to an error similar this:

_pickle.PicklingError: Can't pickle <class 'ValueError'>: it's not the same object as builtins.ValueError

The simplest solution would be to modify the exception directly, as I have done in this PR. The resulting printed error will be exactly the same for the most common cases of exceptions with either no arguments or a single string argument. For exceptions with multiple arguments the message will be less readable but I can't think of a common use case for that anyway.

@sguada sguada requested a review from dhr December 7, 2019 22:11
@dhr dhr removed the cla: yes label Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants