PermanentTaskFailure:'模块'对象没有属性'迁移' [英] PermanentTaskFailure: 'module' object has no attribute 'Migrate'

查看:145
本文介绍了PermanentTaskFailure:'模块'对象没有属性'迁移'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在google appengine上使用Nick Johnson的Bulk Update库(http://blog.notdot.net/2010/03/Announcing-a-robust-datastore-bulk-update-utility-for-App-Engine) 。它适用于其他任务,但出于某种原因使用以下代码:

  from google.appengine.ext import db 
from myapp.main.models import Story,Comment
import bulkupdate

class迁移(bulkupdate.BulkUpdater):
DELETE_COMPLETED_JOBS_DELAY = 0
DELETE_FAILED_JOBS = False
PUT_BATCH_SIZE = 1
DELETE_BATCH_SIZE = 1
MAX_EXECUTION_TIME = 10
$ b $ def get_query(self):
return Story.all()。filter(hidden, False).filter(visible,True)
$ b $ def handle_entity(self,entity):
comments = entity.comment_set
评论评论:
s = Story()
s.parent_story = comment.story
s.user = comment.user
s.text = comment.text
s.submitted = comment.submitted
self.put(s)

job = Migrate()
job.start()

我的日志中出现以下错误:

 试图执行的永久性失败任务
Traceback(最近一次调用最后一次):
在$ b后的文件/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py,第258行$ b run(self.request.body)
运行
的文件/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py,第122行PermanentTaskFailure(e)
PermanentTaskFailure:'module'object has no attribute'Migrate'

它对我来说似乎很奇怪。显然,班级正处于工作之上,他们在同一个文件中,显然是job.start被称为。为什么不能看到我的Migrate类?



编辑:我在更新版本的代码中添加了这个更新作业,这不是默认的。我使用正确的URL调用作业(http://version.myapp.appspot.com/migrate)。是否有可能这与App Engine所提供的默认版本不兼容有关系? 解决方案

似乎您的'Migrate'类的声明可能在处理程序脚本中(例如,由app.yaml直接调用的那个)。延迟的一个限制是您不能使用它来调用在处理程序模块中定义的函数。

顺便说一下,我的批量更新库已被弃用,以支持App Engine的映射精简支持;你应该使用它。


I'm using Nick Johnson's Bulk Update library on google appengine (http://blog.notdot.net/2010/03/Announcing-a-robust-datastore-bulk-update-utility-for-App-Engine). It works wonderfully for other tasks, but for some reason with the following code:

 from google.appengine.ext import db
 from myapp.main.models import Story, Comment
 import bulkupdate

 class Migrate(bulkupdate.BulkUpdater):
     DELETE_COMPLETED_JOBS_DELAY = 0
     DELETE_FAILED_JOBS = False
     PUT_BATCH_SIZE = 1
     DELETE_BATCH_SIZE = 1
     MAX_EXECUTION_TIME = 10

     def get_query(self):
         return Story.all().filter("hidden", False).filter("visible", True)

     def handle_entity(self, entity):
         comments = entity.comment_set
         for comment in comments:
             s = Story()
             s.parent_story = comment.story
             s.user = comment.user
             s.text = comment.text
             s.submitted = comment.submitted
             self.put(s)

 job = Migrate()
 job.start()

I get the following error in my logs:

Permanent failure attempting to execute task
Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 258, in post
    run(self.request.body)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 122, in run
    raise PermanentTaskFailure(e)
PermanentTaskFailure: 'module' object has no attribute 'Migrate'

It seems quite bizarre to me. Clearly that class is right above the job, they're in the same file and clearly the job.start is being called. Why can't it see my Migrate class?

EDIT: I added this update job in a newer version of the code, which isn't the default. I invoke the job with the correct URL (http://version.myapp.appspot.com/migrate). Is it possible this is related to the fact that it isn't the 'default' version served by App Engine?

解决方案

It seems likely that your declaration of the 'Migrate' class is in the handler script (Eg, the one directly invoked by app.yaml). A limitation of deferred is that you can't use it to call functions defined in the handler module.

Incidentally, my bulk update library is deprecated in favor of App Engine's mapreduce support; you should probably use that instead.

这篇关于PermanentTaskFailure:'模块'对象没有属性'迁移'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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