ConjunctionNode()的错误是什么意思?

时间:2014-06-09 14:17:08

标签: python google-app-engine memcached app-engine-ndb gae-quotas

我的应用程序遇到配额问题,我想在我的代码中正确处理这些情况。仅针对Datastore Read Operations达到了限制,但在尝试从memcache中读取数据时,我遇到TypeError: ConjunctionNode() requires at least one node异常 - entries = memcache.get('mykey')

为什么会发生这种异常?

异常详情:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 266, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1519, in __call__
    response = self._internal_error(e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~myapp/1.373233284460557570/myapp.py", line 595, in get
    entries = memcache.get('mykey')
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 559, in get
    results = rpc.get_result()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
    return self.__get_result_hook(self)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 624, in __get_hook
    self._do_unpickle)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 271, in _decode_value
    return do_unpickle(value)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/memcache/__init__.py", line 401, in _do_unpickle
    return unpickler.load()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/query.py", line 550, in __new__
    raise TypeError('ConjunctionNode() requires at least one node.')
TypeError: ConjunctionNode() requires at least one node.

UPD 即可。这是我保存到memcache的内容:

entries = MyModel.query()
entries = entries.fetch(keys_only=True)
entries = random.sample(entries, 10)
entries = [list_key.get() for list_key in entries]
memcache.set('mykey', entries, 60*60*24)

UPD2 即可。在线memcache查看器显示存储的以下值(只是第一部分如下所示):

  

类型:对象   ..cgoogle.appengine.ext.ndb.query.Query.q。。)●} Q值。(U._Query__projectionq.NU._Query__filtersq.cgoogle.appengine.ext.ndb.query.ConjunctionNode.q)。Q值。 } qU_ConjunctionNode__nodesq。]●(cgoogle.appengine.ext.ndb.query.FilterNode.q。。)●} q值。(U._Filt

1 个答案:

答案 0 :(得分:0)

我认为这只是因为你试图将一个pickle的Query对象放入memcache,但是Query对象不是可以发现的。

在这种情况下,我所做的是在将查询放入缓存之前将其转换为列表。如果您的代码并不关心区别(即,如果它没有调用.filter()或类似的东西),那么它也可能适合您。