与谷歌应用程序引擎异步启动网址抓取后台 [英] Start backend with async urlfetch on Google App Engine

查看:185
本文介绍了与谷歌应用程序引擎异步启动网址抓取后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与几个GAE的功能试验。

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

后端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.

当我在我的处理内部,使用一切worikng罚款:

Everything is worikng fine when I use inside my handlers:

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

但我想这个调用为异步由于该后端可能需要最多10分钟才能完成它的工作的原因。

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.

于是我改变了上述code为:

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?

感谢大家。

推荐答案

使用RPC的异步调用,而不调用get_result()的RPC对象将不获资助的网址抓取将被调用。一旦你的code退出该未完成将被中止未决的异步调用。

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.

使处理异步的唯一方法是要排队code在推送队列中。

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

这篇关于与谷歌应用程序引擎异步启动网址抓取后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆