简体   繁体   中英

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)

I know that backends get a call to /_ah/start which initialises them and lets GAE know the backend has started. Is it safe to start the pull process from StartHandler, ie

f = urllib2.urlop
for l in f:
     deferred.defer(doMyStuff,l)

I think the answer is to have a StartHandler along the lines of:

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.

Advice and comments welcome.

Answer to this question. Google App Engine will not let this work. I gave it up and used a different cloud provider , because life's too short, and python should be python, anywhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM