rpc.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:appbackendapi 作者: codesdk 项目源码 文件源码
def get(self):
        # [START urlfetch-rpc-callback]
        def handle_result(rpc):
            result = rpc.get_result()
            self.response.write(result.content)
            logging.info('Handling RPC in callback: result {}'.format(result))

        urls = ['http://www.google.com',
                'http://www.github.com',
                'http://www.travis-ci.org']
        rpcs = []
        for url in urls:
            rpc = urlfetch.create_rpc()
            rpc.callback = functools.partial(handle_result, rpc)
            urlfetch.make_fetch_call(rpc, url)
            rpcs.append(rpc)

        # ... do other things ...

        # Finish all RPCs, and let callbacks process the results.

        for rpc in rpcs:
            rpc.wait()

        logging.info('Done waiting for RPCs')
        # [END urlfetch-rpc-callback]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号