(With the implemented methods not shown) Almost everything works well.
However, I have one failing test, which uses the Python mulitprocessing library. The code boils down to something like:
def _func(obj_with_cal, *args, **kwargs):
return obj_with_cal.value(*args, **kwargs)
from multiprocessing import Pool
from functools import partial
func = partial(_func, *args, **kwargs))
p = Pool(defaults.pool)
results = p.map(func, list_of_objs_with_cal)
p.close()
The Error I receive is:
TypeError: cannot pickle 'builtins.Cal' object
I have never had use for pickle in Python, nor serde in Rust, so am unfamiliar with these in general. The issue: Pickle Support · Issue #100 · PyO3/pyo3 · GitHub seems to discuss this but at a technical level that I don't currently understand.
I have tried the derive the Serialize and Deserialize traits for Cal but their container types dont support it.
Can anyone give a holistic, helpful description of what I am facing here, and possibly suggest the most straightforward way ti implment a fix, if indeed one exists?
Are you using indexmap::IndexSet? In that case, you can enable the serde feature of indexmap to add (de-)serialization support. That should enable you to derive Serialize and Deserialize. AFAIU the discussion in the issue you linked, the next step would be to follow the gist that was shared in this reply, possibly enhancing it as described here.
Since I am building a Python project with rust extensions my rust extension is called "py-project.rust-extension" When I added this to the struct it could find it and pickle it: