Python +烧杯错误:无法在<module'classes'=“” from =“” c:\\ users \\ documents \\ classes.py'=“”>

时间:2018-07-09 20:56:06

标签: python-3.x beaker

我正在从Beaker调用方法invalidate(),并将错误抛出以下错误。奇怪的是,几天前它可以正常工作,并且错误中引用的“属性'Field'”实际上是我最近从代码中删除的类。

为什么烧杯会引用一个不再存在的类而引发错误?

Traceback (most recent call last):
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\flask\_compat.py", line 33, in
reraise
raise value
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\rodolfo.ortiz\Documents\test\main.py", line 25, in predict
schema_manager.invalidateCache("tenant", "schemaServiceUrl", "useLocalSchemaInfo", "useLocalValuesInfo")
  File "C:\Users\rodolfo.ortiz\Documents\test\schema_manager.py", line 31, in invalidateCache
cache.invalidate(GetSchemaAndFields, "GetSchemaAndFields", tenant, schemaServiceUrl, useLocalSchemaInfo, useLocalValuesInfo)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\cache.py", line 542, in
invalidate
_cache_decorator_invalidate(cache, key_length, args)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\cache.py", line 615, in
_cache_decorator_invalidate
cache.remove_value(cache_key)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\cache.py", line 327, in
remove_value
mycontainer.clear_value()
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\container.py", line 420, in clear_value
self.namespace.acquire_write_lock()
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\container.py", line 223, in acquire_write_lock
self.open('c', checkcount=True, replace=replace)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\container.py", line 240, in open
self.do_open(flags, replace)
  File "C:\Users\rodolfo.ortiz\.virtualenvs\test\lib\site-packages\beaker\container.py", line 673, in do_open
self.hash = pickle.load(fh)
AttributeError: Can't get attribute 'Field' on <module 'classes' from 'C:\\Users\\rodolfo.ortiz\\Documents\\test\\classes.py'>

1 个答案:

答案 0 :(得分:0)

我能够解决这个问题,结果发现Beaker有一个文件夹,用于存储缓存。删除文件夹C:\Users\rodolfo.ortiz\Documents\Beaker\tmp\cache消除了错误。

我的猜测是正在检索缓存的旧副本,并且由于模型不再与缓存中的内容匹配,因此引发了错误。但是该错误具有误导性,因为它提到了实际上是一个类的属性。