[英]Google App Engine backend starts
I am writing a GAE application that when it starts needs to initialise a connection to a third party service, and then run a continuous check in the background (essentially pulling data from third party and pushing it to a GAE task queue) 我正在编写一个GAE应用程序,该应用程序启动时需要初始化与第三方服务的连接,然后在后台运行连续检查(基本上是从第三方提取数据并将其推送到GAE任务队列)
I know that backends get a call to /_ah/start which initialises them and lets GAE know the backend has started. 我知道后端会调用/ _ah / start来对其进行初始化,并让GAE知道后端已经启动。 Is it safe to start the pull process from StartHandler, ie 从StartHandler开始拉动过程是否安全,即
f = urllib2.urlop
for l in f:
deferred.defer(doMyStuff,l)
I think the answer is to have a StartHandler along the lines of: 我认为答案是按照以下方式使用StartHandler:
class StartHandler(webapp2.RequestHandler):
def get(self):
logging.info("Handler started")
key = self.request.get('key')
taskqueue.add('/backend/startdata', params={'key':key}, target='1.backend0')
and then have the handler for /backend/startdata
run the loop. 然后让/backend/startdata
的处理程序运行循环。
Advice and comments welcome. 咨询和评论欢迎。
Answer to this question. 回答这个问题。 Google App Engine will not let this work. Google App Engine不允许这样做。 I gave it up and used a different cloud provider , because life's too short, and python should be python, anywhere. 我放弃了它,使用了其他的云提供商 ,因为生命太短了,python在任何地方都应该是python。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.