-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to stop the stream #31
Comments
If you use r's iterator I don't see the necessity of a stop function. Maybe you have something else in mind. Can you show me a code example of how you would use |
r = api.request('statuses/filter', {'track':TRACK_TERM})
for item in r.get_iterator():
if stop(item):
break
process_tweet(item)
def stop(item):
if 'code' in item and item['code'] is 88:
print "Rate limit exceeded."
return True
else:
return False |
The reason I want to stop the |
It really depends on what you want to do. For example, you could get a tweet and change the request and get another tweet this way: r = api.request('statuses/filter', {'track':TRACK_TERM1})
tweet = next(r.get_iterator())
print tweet['text']
r = api.request('statuses/filter', {'track':TRACK_TERM2})
tweet = next(r.get_iterator())
print tweet['text'] You can see from this example, which uses I hope that clarifies something. |
If I understand your example it allows me to search for many things at the same time? |
I think you are misunderstanding. The last example does not do a simultaneous search. It does exactly what you said:
|
Yes, I am pretty sure there is something here I do not understand. My code first looks like this:
That works fine. But later in the script I change the value of
The old for loop still outputs the results from the first |
That sounds right, because the What I suggest is this. First, ask yourself what is the condition you want the |
It feels like I am looking at this in the wrong way. What you say makes sense, but since I do not have that much experience with Python I am having a hard time implementing it. |
It would be really nice to have a function to stop the stream when running
r = api.request('statuses/filter', {'track': TRACK_TERM})
.Something like
r.stop()
.The text was updated successfully, but these errors were encountered: