我正在使用 python-twitter 和 Twitter Streaming API 来尝试收集来自英国的关于特定主题的推文。我正在使用的循环是:
while True:
try:
for item in api.GetStreamFilter(locations = UK_BB, stall_warnings = True):
tweet = parse_tweet(item)
if relevant(tweet):
save_tweet(tweet)
except Exception as err:
logging.exception("Error at %s:", datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p"))
这个过程可以正常运行大约五分钟,保存相关的推文。然而,大约五分钟后,每次都停止来自 API 的数据。我没有从流中收到任何异常或任何异常消息。我对流打开的连接不超过一个。API 凭据似乎很好,我的连接没有问题。重新启动连接将使其再工作五分钟,但随后问题将再次出现。
有谁知道这里可能出了什么问题?