make world picklable
Opened this issue · 0 comments
sbarthelemy commented
Here is an example of WorldObserver that tries to pickle world at each simulation timestep
#import cPickle as pickle
import pickle
class WorldPickler(WorldObserver):
def __init__(self, world, file):
self._file = open(file, 'wb')
self._dumps = []
self._world = world
def init(self):
pass
def update(self, dt):
world = self._world
self._dumps.append(cPickle.dumps(world, protocol=-1))
def finish(self):
pickle.dump(self._dumps, self._file, protocol=-1)
However, it fails with this error:
pickle.PicklingError: Can't pickle <type 'instancemethod'>: it's not found as __builtin__.instancemethod