jahschwa / sibyl

a python chatbot with a focus on XBMC
GNU General Public License v3.0
7 stars 6 forks source link

saving state can die if class definitions mismatch #83

Open jahschwa opened 3 years ago

jahschwa commented 3 years ago

If class definitions change pickling can fail. I'm not certain if there's a practical remediation for this; might just be a limitation we have to live with. Maybe requiring custom classes that get pickled to have their own pickle overrides is enough?

If nothing else, the pickle code probably needs to be in a try statement; this caused an unclean exit.

Traceback (most recent call last):
  File "/home/laptopdude/apps/sibyl/run.py", line 86, in <module>
    main()
  File "/home/laptopdude/apps/sibyl/run.py", line 65, in main
    reboot = bot.run_forever()
  File "/home/laptopdude/apps/sibyl/lib/sibylbot.py", line 1254, in run_forever
    pickle.dump(d,f,-1)
  File "/usr/lib/python2.7/pickle.py", line 1376, in dump
    Pickler(file, protocol).dump(obj)
  File "/usr/lib/python2.7/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 687, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 692, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 687, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 691, in _batch_setitems
    save(k)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 396, in save_reduce
    save(cls)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 759, in save_global
    (obj, module, name))
pickle.PicklingError: Can't pickle <class 'db.Key'>: it's not the same object as db.Key