推文和关注者使用Google App Engine获取应用 [英] Tweets and followers fetching app with Google App Engine

查看:85
本文介绍了推文和关注者使用Google App Engine获取应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google App Engine在Python中构建一个应用,该应用先获取特定帐户的关注者,然后获取其推文.我将其基于此模板并进行更改使其适应我的需求.

I'm trying to build an app in Python with Google App Engine that fetches followers of specific accounts and then their tweets. I'm basing it on this template and changing it to adapt it to what I need.

目前的问题是,当我尝试获取关注者时,由于Twitter API等待时间,我得到了DeadlineExceededError.

The issue at the moment is that when I try to fetch followers, I get an DeadlineExceededError due to the Twitter API waiting time.

我发现了关于如何解决相同问题的文章,我认为就我而言,最好的解决方案是使用后端,但我注意到它们已被弃用.

I have found this post on how to fix the same problem and I think that in my case the best solution would be to use backends, but I noticed that they are deprecated.

有人知道不使用不推荐使用的模块怎么能达到相同的结果吗?

Does someone know how I can achieve the same result without the deprecated module?

推荐答案

您可以使用几个选项来执行长时间运行的任务:

You have a couple options that you can use for long-running tasks:

  • 使用GAE任务队列:GAE提供了推入和拉出队列,使您可以在单个请求之外进行异步工作.
  • 使用Cloud Pub/Sub :一种拉入队列,这将使您的App Engine应用程序可以在每次您想要获取关注者或获取推文时发布一条消息.然后,订阅者将从队列中获取消息,执行长时间运行的任务,然后将结果放入某个数据存储中.
  • 使用GAE服务:这将允许您创建后台服务,并
  • Use GAE Task Queues: GAE provides push and pull queues which allow you to do work asynchronously outside of the individual request.
  • Use Cloud Pub/Sub: A type of pull queue, this would allow your App Engine app to publish a message every time you wanted fetch followers or fetch tweets. The subscriber would then take the message from the queue, perform a long-running task, and then put the result into some datastore.
  • Use GAE Services: This would allow you to create a background service and manually scale it to run as long as you need.

这篇关于推文和关注者使用Google App Engine获取应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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