Python Google App Engine Cron作业/计划任务不工作

2024-09-28 22:34:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建这个cron作业来获取twitter提要并将其存储在数据存储中。我什么都试过了,但我的亲信不管用。我读了下面的文章/教程和一些stackoverflow问题,但我不能解决这个问题。在

https://developers.google.com/appengine/docs/python/config/cron

http://cloudartisan.com/posts/2010-06-02-scheduled-tasks-with-google-app-engine-python/

这是我的密码

这是克罗恩·伊马尔在

cron:
- description : capture twitter feed 
  url : /twittertask
  schedule: every 1 minutes
  target: version-2

这是我需要做这项工作的班级。在

^{pr2}$

这是应用程序ymal在

application: cronjob
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: index.app

- url: /twittertask
  script: twittertask.app

这是索引.py在

import webapp2

class MainPage(webapp2.RequestHandler):
  def get(self):
      self.response.headers['Content-Type'] = 'text/plain'
      self.response.write('Hello, Check Admin')

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)

def main():

    run_wsgi_app(application)

if __name__ == "__main__":
    main()

好吧,我找不到错误在哪里。我在我的开发服务器上进行了测试。我没有上传到谷歌应用引擎。在


Tags: selfcomappurlapplicationmainversiondef
2条回答

Cron不能在本地开发服务器上工作。把它上传到云端就可以了。在

在本地访问应用程序服务器:

http://127.0.0.1:8080/_ah/admin

然后点击“Cron jobs”。在

^{pr2}$

它会说“在生产中,这个会在这个时候运行”

你的日程安排在这里。在

问题出在你的应用程序yaml. URL从上到下匹配,但第一个处理程序匹配所有URL。移动twittertask条目,使其位于handlers下的第一个条目。在

相关问题 更多 >