Cron作业未与appengin一起运行

2024-09-27 23:29:00 发布

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

在appengine中,我创建了一个cron作业,它在间隔2分钟后执行,并将一些数据发布到我的facebook墙上。在

但每隔两分钟我在appengine上看到日志后,我会看到以下几行:

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

我的脸书墙上什么也没贴。在

但是当我手动执行cron作业url时(通过在浏览器中直接点击),应用程序会在我的墙上发布一些内容。在

{cd1>在这里^

^{pr2}$

这是我的网址.py在

from django.conf.urls import patterns, include, url
from django.conf import settings
from django.conf.urls.static import static
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    url(r'^crona/$', 'testapp.views.crona', name='crona'),
    url(r'^admin/', include(admin.site.urls)),
)+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

这是视图

def crona(request):
   logging.info("hello")
   croned=CronEntries.objects.all().order_by('posted_datetime')[0]

   if croned.email_id=='n*******@gmail.com':
      try:
         access_token="##############################################################"
         graph = facebook.GraphAPI(access_token)
         graph.put_object("me", "feed", message=croned.status_cron)
         croned.delete()
      except Exception as e:
         logging.info(e)
      else:
         return HttpResponse("ok")

给你克罗恩·亚姆在

cron:
- description: post on fb
  url: /crona
  schedule: every 2 minutes

Tags: thetodjangofromimporturlforyour
1条回答
网友
1楼 · 发布于 2024-09-27 23:29:00

您的url处理程序url(r'^crona/$', ...需要一个尾部斜杠,cron url省略了这一点。{cron>如果你不想让你的应用程序{cd2>附加一个},因为你不想让你的应用程序{cran3}附加一个。在

相关问题 更多 >

    热门问题