asdf
asdf copied to clipboard
`AsdfFile` instances are not pickleable
Description of the problem
AsdfFile
instances are not pickleable.
Example of the problem
import asdf, pickle
af = asdf.AsdfFile({'a': 1})
pickle.dumps(af)
Fails with
AttributeError: Can't pickle local object 'ValidatorManager._get_jsonschema_validator.<locals>._validator'
System information
asdf version: main python version: 3.10 operating system: mac os (m1)
To provide a bit more context. The lack of "pickle-ability" means AsdfFile
instances do not play well with multiprocessing
:
def get_a(af):
return af['a']
with multiprocessing.Pool(4):
pool.map(get_a, [af])
Fails with the above error.