提交 412665cd authored 作者: James Bergstra's avatar James Bergstra

added robustness to cmodule to handle keys that can be pickled but not un-pickled

上级 39f61ab1
......@@ -377,10 +377,13 @@ class ModuleCache(object):
key_broken = True
if not key_broken:
try:
key_from_file = cPickle.load(file(key_pkl))
if key != key_from_file:
raise Exception("key not equal to unpickled version (Hint: verify the __eq__ and __hash__ functions for your Ops", (key, key_from_file))
self.loaded_key_pkl.add(key_pkl)
self.loaded_key_pkl.add(key_pkl) # adding the key file to this set means it is a versioned key
except cPickle.UnpicklingError:
warning('Cache failure due to un-loadable key', key)
self.entry_from_key[key] = name
self.module_from_name[name] = module
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论