Question

I am experimenting with several of GAE's features.

I 've built a Dynamic Backend but I am having several issues getting this thing to work without task queues

Backend code:

class StartHandler(webapp2.RequestHandler):

    def get(self):
    #... do stuff...    

if __name__ == '__main__':
    _handlers = [(r'/_ah/start', StartHandler)]
    run_wsgi_app(webapp2.WSGIApplication(_handlers))

The Backend is dynamic. So whenever it receives a call it does it's stuff and then stops.

Everything is worikng fine when I use inside my handlers:

url = backends.get_url('worker') + '/_ah/start'
urlfetch.fetch(url)

But I want this call to be async due to the reason that the Backend might take up to 10 minutes to finish it's work.

So I changed the above code to:

url = backends.get_url('worker') + '/_ah/start'
rpc = urlfetch.create_rpc()
urlfetch.make_fetch_call(rpc, url)

But then the Backend does not start. I am not interested into completion of the request or getting any data out of it.

What am I missing - implementing wrong?

Thank you all

Was it helpful?

Solution

Using RPC for async call without calling get_result() on the rpc object will not grantee that the urlfetch will be called. Once your code exits the pending async calls that were not completed will be aborted.

The only way to make the handler async is to queue the code in a push queue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top