Skip to main content
 首页 » 编程设计

python之Cron 作业错误 : accessing Datastore and emailing

2025年05月04日14sxdcgaq8080

对于我的网络应用程序,我编写了这个 cron 作业,它应该访问 Google App Engine 数据存储区中的数据,解析网站,然后通过电子邮件发送结果。

但是,我在请求 cron 作业时收到 404 错误,并且不知道如何解决这个问题。这是我访问数据库的方式吗?

谢谢

这是我的 update.py:

from google.appengine.ext import db 
 
import urllib2 
import string 
 
import myWebapp 
 
## CRON 1:                                                                       
## Check all x in B.db if courses changed                                    
##  Yes:                                                                         
##    email x                                                                    
##    if x.things all != 'Closed':                                              
##        remove from db                                                         
 
boo = myWebapp.B.all() 
 
if boo.count() >0: 
    for b in boo.run(batch_size=1000): 
        currentThings = b.mThings 
        newThings = myWebapp.updateStatus(b.mThings) 
        if currentThings != newThings: 
            b.mThings = newThings 
            myWebapp.sendTextAndEmail(b.mEmail, b.mPhoneNumMail, 
                         b.mThings, "myWebapp Update") 
        numClosed = 0 
        for c in b.mThings:           
            if c[2] == 'Closed': 
                numClosed += 1 
        if numClosed == 0: 
            b.delete() 

这是我的 cron.yaml:

cron: 
- description: check things and email if change 
  url: /.update.py 
  schedule: every 5 minutes 
  timezone: US/Pacific 

请您参考如下方法:

文档说明:

To test a cron job, sign in as an administrator and visit the URL of the handler in your browser.

Securing URLS for CRON

如果您仍然收到 404,建议您创建一个“正常”处理程序并从那里获取它。

您访问数据库的方式或其他方式与 404(未找到)错误无关。