dav*_*ola 9 python google-app-engine google-cloud-datastore
我正在google appengine上使用Nick Johnson的批量更新库(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 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()
Run Code Online (Sandbox Code Playgroud)
我的日志中出现以下错误:
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'
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎很奇怪.很明显,这个课程正好在工作之上,他们在同一个文件中,显然是job.start正在被调用.为什么不能看到我的Migrate类?
编辑:我在更新版本的代码中添加了此更新作业,这不是默认值.我使用正确的URL(http://version.myapp.appspot.com/migrate)调用该作业.是否有可能这与App Engine提供的"默认"版本无关?
你的'Migrate'类声明似乎可能在处理程序脚本中(例如,app.yaml直接调用的那个).延迟的限制是您不能使用它来调用处理程序模块中定义的函数.
顺便提一下,我的批量更新库已被弃用,以支持App Engine的mapreduce支持; 你可能应该使用它.
归档时间: |
|
查看次数: |
1409 次 |
最近记录: |