Multiprocessing JSBSim with Python #516
Replies: 2 comments 16 replies
-
Hi @sr71684, Indeed Cython extension types can't be pickled when they contain the So your best course of action is to create a new Python class that inherits from class PickleFDMExec(jsbsim.FGFDMExec):
def load_model(self, model_name):
self.model_name = model_name # Store a copy of the model name
jsbsim.FGFDMExec.load_model(self, model_name)
def __reduce__(self):
return rebuild, (self.get_root_dir(), self.model_name, self.get_delta_t())
# Tells pickle how to rebuild the FDM from the reduced data.
def rebuild(root_dir, model_name, dt):
fdm = jsbsim.FGFDMExec(root=root_dir)
fdm.load_model(model_name)
fdm.set_dt(dt)
return fdm |
Beta Was this translation helpful? Give feedback.
-
This topic has been moved to JSBSim Discussions as per the issue template statement: Support for this topic will therefore continue within this discussion. Thanks for your understanding. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When attempting to pass an FGFDMExec instance into a python processing pool, JSBSim returns the following error:
This happens because FGFDMExec can't be trivially pickled.
Does there exist a way to pickle FGFDMExec such that the above error is avoided?
Minimum working example:
Environment
Beta Was this translation helpful? Give feedback.
All reactions