App Engine Python: AttributeError: 'module'

2019-07-16 12:26发布

I am getting this error just in production. On localhost it works well.

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/s~ordenaacoes/2.357768699674437719/controllers/mainh.py", line 74, in get
    'stocks': goodStocks(),
  File "/base/data/home/apps/s~ordenaacoes/2.357768699674437719/controllers/mainh.py", line 108, in goodStocks
    goodStocks = memcache.get("goodStocks")
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/memcache/__init__.py", line 574, in get
    results = rpc.get_result()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
    return self.__get_result_hook(self)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/memcache/__init__.py", line 639, in __get_hook
    self._do_unpickle)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/memcache/__init__.py", line 271, in _decode_value
    return do_unpickle(value)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/memcache/__init__.py", line 412, in _do_unpickle
    return unpickler.load()
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py", line 852, in load
    dispatch[key](self)
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py", line 1084, in load_global
    klass = self.find_class(module, name)
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py", line 1119, in find_class
    klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'Stock'

Stock is one class of my models. I tested with python 2.5 on localhost too.

The line that gives the error is the access to memcache (get function).
I have changed the project and maybe the type of the data I put in memcache is different. Do I have some way to clean the data on memcache?

Any idea?

2条回答
叼着烟拽天下
2楼-- · 2019-07-16 12:42

Most likely you have a pickled version of an object in memcache that doesn't match your new code. Here's an old question on flushing memcache, the answer should apply to your case:

How can I have Google App Engine clear memcache every time a site is deployed?

查看更多
女痞
3楼-- · 2019-07-16 12:49

As of release 1.6.4 there is a Memcache Viewer in the Admin Console. It includes a "Flush Cache" button that should do exactly what you need.

查看更多
登录 后发表回答