botocore exceptions are not picklable

Created on 5 Mar 2016  路  6Comments  路  Source: boto/botocore

they need to take a "msg" argument, and all other arguments must be optional:

http://stackoverflow.com/questions/16244923/how-to-make-a-custom-exception-class-with-multiple-init-args-pickleable. I've attempted fixing this in PR: https://github.com/boto/botocore/pull/835

simple testcase:

try:
    raise botocore.exceptions.NoCredentialsError
except Exception as e:
    b = pickle.dumps(e)
    e = pickle.loads(b)
feature-request

Most helpful comment

@thehesiod I've opened #1191 that uses __reduce__ and which also tackles #899 to have a consistent exception error set. Bonus feature is being able to import the exception classes under botocore.exceptions.<service>.<exceptioncls>, e.g. as botocore.exceptions.s3.BucketAlreadyExists

All 6 comments

Tracking discussion of this over in the PR: #835.

this is now further compounded by the metaclass instantiation of ClientError, which return things like botocore.errorfactory.NoSuchKey, which can't pickle because that class does not exist in that module. I think a better impl is probably implementing the __reduce__ methods

@thehesiod I've opened #1191 that uses __reduce__ and which also tackles #899 to have a consistent exception error set. Bonus feature is being able to import the exception classes under botocore.exceptions.<service>.<exceptioncls>, e.g. as botocore.exceptions.s3.BucketAlreadyExists

cool, closing my PR, for future reference to others, see comments in my PR for use cases as well

I think this can now be closed, @jezdez ?

Yeah it seems to have been fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thehesiod picture thehesiod  路  5Comments

jsha picture jsha  路  3Comments

AlexDiede picture AlexDiede  路  3Comments

eode picture eode  路  5Comments

stig picture stig  路  3Comments