ReferenceProperty无法解决-App Engine [英] ReferenceProperty failed to be resolved -- App Engine

查看:73
本文介绍了ReferenceProperty无法解决-App Engine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个错误,无法找出根本原因.错误如下:"ReferenceProperty无法解析:[u'StatusLog',STATUSLOGSID]".此错误有时仅发生一次,大约一天一次或两次.产生此错误的脚本成功的方式多于失败的方式.关于该错误的最奇怪的事情是它无法解析引用属性,这种情况永远都不会发生(就这种情况而言),因为所引用的实体从未被我的webapp删除.此外,我没有生成被引用的密钥,而是Google App Engine.相关代码在下面列出.

I am running into an error that I am unable to isolate the root cause of. The error is the following: "ReferenceProperty failed to be resolved: [u'StatusLog', STATUSLOGSID]". This error only occurs sometimes, about once or twice a day. The scripts that generate this error succeed way more often than they fail. The strangest thing about the error is that it is failing to resolve a reference property, which should never be the case (in regards to this situation) because the entities that are being referenced are never deleted by my webapp. Furthermore, I am not generating the keys that are being referenced, the Google App Engine is. The relevant code is listed below.

GAE交易:

def updateStatus(key):
    hbo = HBO.get(key)
    hbo.updateStatus()
    hbo.put()

class HBOCRON(webapp2.RequestHandler):
    def get(self):
        keys = db.Query(HBO, keys_only = True).filter("inactive = ", False)
        XG_ON = db.create_transaction_options(xg=True)
        for key in keys: db.run_in_transaction_options(XG_ON, updateStatus, key)

app = webapp2.WSGIApplication([('/cron/hbo', HBOCRON)],debug=True)

其他两个相关功能...

Two other relevant functions...

def logStatus(self):
    self.status = StatusLog(
        hbo = self,
        prev = self.status,
        date = datetime.datetime.now(),
        on = self.online(),
        up = self.upToDate(),
        dns = self.DNS_update_needed,
        dis = self.manually_disabled).put()

def updateStatus(self):
    status = self.status
    if status is None \
        or status.on != self.online() \
        or status.up != self.upToDate() \
        or status.dns != self.DNS_update_needed:
        self.logStatus()
        self.flagged = True
    elif status.dis != self.manually_disabled:
        self.logStatus()

跟踪:

ReferenceProperty failed to be resolved: [u'StatusLog', 248327L]
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~hs-hbo/1.357660268729453201/api/hbo/getCheckin.py", line 88, in post
    (hbo, data) = db.run_in_transaction_options(XG_ON, checkinTransaction, self.request)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/datastore.py", line 2476, in RunInTransactionOptions
    ok, result = _DoOneTry(new_connection, function, args, kwargs)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/datastore.py", line 2498, in _DoOneTry
    result = function(*args, **kwargs)
  File "/base/data/home/apps/s~hs-hbo/1.357660268729453201/api/hbo/getCheckin.py", line 33, in checkinTransaction
    hbo.updateStatus()
  File "/base/data/home/apps/s~hs-hbo/1.357660268729453201/shared/datastore.py", line 116, in updateStatus
    return self.logStatus()
  File "/base/data/home/apps/s~hs-hbo/1.357660268729453201/shared/datastore.py", line 102, in logStatus
    prev = self.status,
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/db/__init__.py", line 3597, in __get__
    reference_id.to_path())
ReferencePropertyResolveError: ReferenceProperty failed to be resolved: [u'StatusLog', 248327L]

感谢您提供任何见解/帮助/答案/建议!

Thanks for any insight/help/answers/suggestions!

推荐答案

当您尝试解析引用属性(通过取消引用,例如(MyModel.MyReferenceProp.foo),并且不再引用该属性)时,会发生这种情况存在-因为已被删除.

This happens when you attempt to resolve a reference property (by dereferencing it - for instance, (MyModel.MyReferenceProp.foo), and the property being referenced no longer exists - because it has been deleted.

您需要修改代码以在取消引用可能已删除的实体时捕获此异常,并进行适当处理.

You need to modify your code to catch this exception when you dereference an entity that may have been deleted, and handle it appropriately.

这篇关于ReferenceProperty无法解决-App Engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆