gae python cron 500错误

时间:2015-12-28 10:42:30

标签: python google-app-engine cron

我努力让一个cron工作工作并得到一个500错误。

我的app.yaml文件包含以下处理程序,因此它会选择代码

- url: /.*
  script: main.application

这是我的cron.yaml

cron:
- description: my cron job
  url: /daily_batch
  schedule: every 10 minutes

main.py包含以下内容:

application = webapp2.WSGIApplication([
    ('/', MainPage),
    ('/daily_batch',DailyBatch),
], debug=True)

这就是我编写DailyBatch的方式

class DailyBatch ():
    def get(self):
        myDefaults = DefaultData.query().fetch()
        for d in myDefaults:
            counter = 0

如果我从一个网址运行它,它工作正常,但从cron给我一个500错误。我是愚蠢的。怎么样?

这是我得到的错误信息

ERROR    2015-12-28 10:57:20,056 webapp2.py:1552] this constructor takes no arguments

Traceback (most recent call last):

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__

    rv = self.handle_exception(request, response, e)

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__

    rv = self.router.dispatch(request, response)

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher

    return route.handler_adapter(request, response)

  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1101, in __call__

    handler = self.handler(request, response)

TypeError: this constructor takes no arguments

INFO     2015-12-28 11:57:20,068 module.py:787] default: "GET /daily_batch HTTP/1.1" 500 1216

1 个答案:

答案 0 :(得分:0)

得到了它。谢谢。改为

class DailyBatch(webapp2.RequestHandler)