broken shelf file causes unloadable plugin
Closed this issue · 1 comments
drevicko commented
as far as I can see, if your plugin fails to pickle it's shelf properly (eg: this issue), it then becomes impossible to load the plugin, as an EOF exception is thrown similar to this:
ERROR:senpy.extensions:Error activating plugin emotion-wnaffect - :
Traceback (most recent call last):
File "/Users/drevicko/anaconda/envs/python2/lib/python2.7/site-packages/senpy/extensions.py", line 290, in act
plugin.activate()
File "./emotion-wnaffect.py", line 73, in activate
if 'total_synsets' not in self.sh:
File "/Users/drevicko/anaconda/envs/python2/lib/python2.7/site-packages/senpy/plugins/__init__.py", line 99, in sh
self.__dict__['_sh'] = pickle.load(open(self.shelf_file, 'rb'))
File "/Users/drevicko/anaconda/envs/python2/lib/python2.7/pickle.py", line 1384, in load
return Unpickler(file).load()
File "/Users/drevicko/anaconda/envs/python2/lib/python2.7/pickle.py", line 864, in load
dispatch[key](self)
File "/Users/drevicko/anaconda/envs/python2/lib/python2.7/pickle.py", line 886, in load_eof
raise EOFError
EOFError
It would seem a good idea to issue a warning and fall back on starting the plugin from scratch.
balkian commented
Thanks for the contribution, but I think it's better to throw an exception (and avoid removing the file) unless explicitly told not to.
I've made this change to keep backwards compatibility. It also covers other unpickling errors, not just empty files.
You can now add force_shelf
to your plugin definitions.