I'm using the twitter python package in pip to access the TwitterStream class.
The code for this looks somewhat like this:
twitter_stream = TwitterStream(auth=UserPassAuth('joe', 'joespassword'))
iterator = twitter_stream.statuses.sample()
for tweet in iterator:
# ...do something with this tweet...
I only want the for loop to run for a certain amount of time (say, one minute), so to do this, I inserted a time check in the for loop. My problem though is that if the tweets aren't getting pushed frequently enough, then the body of the for loop never executes and the code essentially hangs until the next tweet comes in.
Does anyone have any ideas on how to get around this? The block param from the docs doesn't return often enough when set to false.
Thanks