【发布时间】:2013-03-22 14:52:44
【问题描述】:
在将 Python Dev Appserver 更新到 Google App Engine 1.7.6(使用 Python 2.7)后,我在使用 memcache 查看器时遇到了一些问题。
我的内存缓存似乎没有更新或不可读。我曾尝试使用应用引擎 memcache 查看器查看 memcache,但是当我输入 memcache 密钥时出现错误。
当我刷新缓存时,一切都照常进行,直到需要再次读取 memcache...
命中率和内存缓存大小正常增加,所以缓存中有东西。此外,当我恢复到应用引擎 1.7.5 时,一切正常。也许其他人遇到过这个问题?
当我输入 memcache 键时,我得到以下信息:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.1\webapp2.py", line 1536, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.1\webapp2.py", line 1530, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.1\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.1\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\admin\admin_request_handler.py", line 80, in dispatch
super(AdminRequestHandler, self).dispatch()
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.1\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.1\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\admin\memcache_viewer.py", line 145, in get
values['value'], values['type'] = self._get_memcache_value_and_type(key)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\admin\memcache_viewer.py", line 74, in _get_memcache_value_and_type
except (pickle.UnpicklingError, AttributeError, EOFError, ImportError,
NameError: global name 'pickle' is not defined
我尝试在我的 main.py 中包含“导入泡菜”,但这是徒劳的。
我已经包含了一些我的代码示例,但希望这不是必需的,我希望它与应用引擎更新有关,而不是我的代码...
我的一些 main.py 文件:
#import pickle
from google.appengine.api import memcache
from google.appengine.ext import db
以及我如何处理 memcache 的示例函数:
def mc_get(key):
a = memcache.get(key)
if a:
val = a
else:
val = None
return val
def mc_set(key, val):
memcache.set(key, val)
如果我想查询我使用的数据库中的用户:
def get_users(update=False):
mc_key = 'USERS'
entries = mc_get(mc_key)
if update or entries is None:
a = User.all()
logging.error('DB---Q - Users')
entries = list(a)
memcache.set(mc_key, entries)
return entries
更新: 我在 Google\google_appengine\google\appengine\tools\devappserver2\admin\memcache_viewer.py 的 memcache_viewer.py 文件中添加了“import pickle” (这是一个错误吗??)
现在,当我输入 memcache 键时,我在 memcache 键输入字段下收到以下错误: 获取用户时出错:无法从缓存中检索值:没有名为 main 的模块
任何帮助将不胜感激,在此先感谢。
【问题讨论】:
-
我试图修改 C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\admin\memcache_viewer.py 中的 memcache_viewer.py 文件,但我'我在权限问题上苦苦挣扎...但是我很难相信 1.7.6 中的更新会要求我在其中一个源文件中包含某些内容,我在使用 1.7.5 时没有添加导入泡菜
-
这绝对是一个错误。当您存储更复杂的结构时会发生这种情况(我认为是对象,但尚未经过全面测试)。我用 memcached 字符串和字典做了一些简单的测试,效果很好。我已经厌倦了最近的所有错误。
-
您应该将其发布到 Google App Engine 的问题跟踪器 - code.google.com/p/googleappengine/issues/list
-
好的,我会将它发布到 Google App Engine 的问题跟踪器,感谢您的意见。我一直在玩已部署的应用程序,它非常善变,仍然没有找到解决方案。如果有解决方案,我会发布。
标签: google-app-engine python-2.7 memcached pickle