我在GAE上运行Django 1.5。我有一个cron作业,它可以遍历数千个urls,并获取它们的“喜欢”计数,并将其保存到DB中。它可以轻松超过10分钟完成它。当我作为一个普通的linux cron在本地运行它时,它可以工作,但是在GAE上这个错误失败了:
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/django-1.5/django/core/handlers/wsgi.py", line 255, in __call__
response = self.get_response(request)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/core/handlers/base.py", line 175, in get_response
signals.got_request_exception.send(sender=self.__class__, request=request)
DeadlineExceededError我的设置:
app.yaml:
- url: /tasks/*
script: myproject.wsgi.application
login: admincron.yaml:
- description: update_facebook_resource
url: /tasks/update_facebook_resource
schedule: every day 04:05
timezone: Europe/Berlinviews.py
def update_facebook_resource(request):
resources = Resource.objects.filter(inactive=0).order_by('id')
url_start = "https://graph.facebook.com/fql?q=select++total_count+from+link_stat+where+url%3D"
url_end = "&access_token=..."
for item in resources:
url = item.link
url_final = url_start+ "%22" + url + "%22" + url_end
data = json.load(urllib2.urlopen(url_final))
likes = data["data"][0]["total_count"]
query = Resource.objects.get(id=item.id)
query.facebook_likes = likes
query.save(update_fields=['facebook_likes'])
return http.HttpResponse('ok')我应该改变什么,如何改变,让GAE让我完成它?我读过这个https://developers.google.com/appengine/articles/deadlineexceedederrors,但它并没有给我真正需要的东西。
谢谢
https://stackoverflow.com/questions/25440763
复制相似问题