应用程序引擎后端配置(python)
当我的GAE服务器试图将大文件发送到EC2 REST服务器时,我的GAE服务器上出现了应用程序引擎后端配置(python),python,google-app-engine,backend,task-queue,Python,Google App Engine,Backend,Task Queue,当我的GAE服务器试图将大文件发送到EC2 REST服务器时,我的GAE服务器上出现了timeout错误。我发现Backendspythonapi对于我的示例来说是一个很好的解决方案,但在配置它时遇到了一些问题 按照一些说明,我在我的项目文件夹中添加了一个简单的backends.yaml。但我仍然收到以下错误,这似乎是我未能创建后端实例 File "\Google\google_appengine\google\appengine\api\background_thread\backgrou
timeout
错误。我发现Backends
pythonapi对于我的示例来说是一个很好的解决方案,但在配置它时遇到了一些问题
按照一些说明,我在我的项目文件夹中添加了一个简单的backends.yaml
。但我仍然收到以下错误,这似乎是我未能创建后端实例
File "\Google\google_appengine\google\appengine\api\background_thread\background_thread.py", line 84, in start_new_background_thread
raise ERROR_MAP[error.application_error](error.error_detail)
FrontendsNotSupported
下面是我的代码,我的问题是:
OutputPage.py
中遇到超时错误,如何让此脚本在后端实例上运行przm\u batchmodel\u backend.py
。在启动我的GAE之后,现在我有两个端口(一个默认端口和一个后端端口)运行我的站点。对吗
app.yaml
backends.yaml
OutputPage.py
przm_batchmodel.py
przm_batchmodel_backend.py
您需要创建一个应用程序“文件”/脚本,以便后端工作。就像你处理主管道一样 比如: app.yaml
- url: /backend.html
script: przm_batchmodel.py
在przm_batchmodel.py上
class BakendHandler(webapp.RequestHandler):
def post(self):
html = 'test'
self.response.out.write(html)
app = webapp.WSGIApplication([('/backend.html', OutputPage)], debug=True)
我还可以建议使用更容易设置的新功能吗
由于评论而编辑
可能安装不是您的问题
从
在后端运行的代码可以启动后台线程,即
可以“超过”生成它的请求。它们允许后端实例
执行任意定期或计划的任务或继续
在请求返回给用户后在后台工作
只能在后端使用backgroundthread
所以请再次编辑。移动代码的以下部分:
t = background_thread.BackgroundThread(target=przm_batchmodel.loop_html, args=[thefile])
t.start()
self.response.out.write(html)
转到后端应用程序感谢您的回复。我按照您的建议添加了
类BakendHandler
,但仍然得到了相同的FrontendsNotSupported
错误。我在windows环境下运行GAE,并使用其GUI按钮启动我的应用程序,对吗?别忘了。在后端使用backgroundthread,而不是前端,正如我在您更新的问题@tao.hong中看到的,您的意思是前端脚本不能包含后端内容,对吗?@tao.hong取决于您如何定义后端内容。主要区别在于请求可能需要更长的时间。还有其他不同之处,比如背景线索,但我记得不多。图像后端作为一个处理程序或应用程序,可以通过60秒的限制,只要您能够支付;-)。谢谢我遵照您的建议,GAE为我创建了一个后端实例(位于不同的本地端口),它看起来与常规实例相同。在backend.yaml中,我只提供非常简短的信息,所以GAE自动克隆了我的常规站点?
def loop_html(thefile):
#parses uploaded csv and send its info. to the REST server, the returned value is a html page.
data= csv.reader(thefile.file.read().splitlines())
response = urlfetch.fetch(url=REST_server, payload=data, method=urlfetch.POST, headers=http_headers, deadline=60)
return response
class BakendHandler(webapp.RequestHandler):
def post(self):
t = background_thread.BackgroundThread(target=przm_batchmodel.loop_html, args=[thefile])
t.start()
app = webapp.WSGIApplication([('/backend.html', BakendHandler)], debug=True)
- url: /backend.html
script: przm_batchmodel.py
class BakendHandler(webapp.RequestHandler):
def post(self):
html = 'test'
self.response.out.write(html)
app = webapp.WSGIApplication([('/backend.html', OutputPage)], debug=True)
t = background_thread.BackgroundThread(target=przm_batchmodel.loop_html, args=[thefile])
t.start()
self.response.out.write(html)