我正在使用以下代码从Twitter使用Python Tweetstream库获取推文,但如果我使用某些没有意义的单词或没有推文的单词,则会阻止流式传输。我想在一段时间后说60秒后超时。我怎么能这样做?
words = ["opera", "firefox", "safari"]
people = [123,124,125]
locations = ["-122.75,36.8", "-121.75,37.8"]
with tweetstream.FilterStream("username", "password", track=words, follow=people, locations=locations) as stream
for tweet in stream:
print "Got interesting tweet:", tweet