Hi
I am using following piece of code. This code gives me outpur when it found Abhishek in my tweet, but it keeps on searching indefinitely. I want to stop after 5-10 searches and come out of this infinite loop saying. “not found”. But this code goes indefinite…please help
class MyStreamer(TwythonStreamer):
def on_success(self,data):
if ‘text’ in data:
track()
def on_stop(self, status_code, data):
print status_code
self.disconnect
stream = MyStreamer(C_KEY,C_SECRET, A_TOKEN, A_SECRET)
stream.statuses.filter(track= “Abhishek”)
I have even tried this, but no success
class MyStreamer(TwythonStreamer):
def on_success(self,data):
if 'text' in data:
track()
def on_stop(self, status_code, data):
print status_code
self.disconnect
def on_error(self, status_code, data):
print status_code
i=1
while i>0:
try:
stream = MyStreamer(C_KEY,C_SECRET, A_TOKEN, A_SECRET)
stream.statuses.filter(track= "Abhishek")
i=i-1
break
except KeyboardInterrupt:
print "moving out of twitter"
break