【发布时间】:2015-08-18 09:31:41
【问题描述】:
我不确定如何在 app.yaml 中为处理程序的脚本设置 URL。我尝试按照文档 (https://cloud.google.com/appengine/docs/python/config/cron) 设置 cron 作业,但我的 cron 在 GAE 中失败。我也收到此错误:
\myproject\app.yaml: threadsafe cannot be enabled with CGI handler: myprojectApp/dsProcess.aggregate
我认为文档假设我没有使用 WSGI,但我对 WSGI 的使用在某种程度上影响了脚本在应用程序中的访问方式。
这是我的项目结构和相关文件:
myproject/
myproject/ (package for project)
urls.py (defers url handling to myprojectApp.urls)
myprojectApp/ (package for actual app)
urls.py
dsProcess.py ( contains the aggregate function my cron should call)
app.yaml
cron.yaml
main.py
在 app.yaml 中,我不确定如何将 url 格式化为 dsProcess.py 的聚合函数:
app.yaml
handlers:
- url: /aggDB
script: myprojectApp/dsProcess.aggregate <-- unsure here
应该改为 myprojectApp.dsProcess.aggregate 吗?
myprojectApp.dsProcess.aggregate.py? myprojectApp.dsProcess.aggregate.app?
我正在运行 Python 2.7.9
cron.yaml
cron:
- description: aggregates db
url: /aggDB
schedule: every 1 mins
main.py
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
myprojectApp/dsProcess.py
def aggregate():
myproject/urls.py 和 myprojectApp/urls.py
我猜我不需要在其中为将被命中的aggDB/ url 设置 url 模式,因为app.yaml 将为我注册并监听该 url 模式。这是正确的吗?
不过,这里有两个 urls.py:
myproject/urls.py
urlpatterns = patterns('',
(r'^', include('myprojectApp.urls')),
)
myprojectApp/urls.py
urlpatterns = patterns('',
...
#don't need to handle this here, let app.yaml handle it?
# (r'^aggDB/$', dsProcess.aggDStoJSON()),
)
我使用 wsgi 会影响我访问脚本的方式吗?如果是这样,如何以及为什么?
【问题讨论】:
标签: python django google-app-engine cron wsgi