Tuesday 17 September 2013

Is it possible to stop twython streaming at certain point of time?

Is it possible to stop twython streaming at certain point of time?

I have the codes for twython streaming and it is working.
def read_cred(file): in_handle = open(file,'r')
cred = {}
for ln in in_handle:
data = ln.strip('\r\n').split('=')
if len(data) > 1:
key = data[0].strip(' ').lower()
value = data[1].strip(' ')
cred[key] = value
else:
print "error in parsing credentials file"
return cred
cred = read_cred(sys.argv[1])
class MyStreamer(TwythonStreamer): def on_success(self, data): act(data)
def on_error(self, status_code, data):
print status_code, data
stream = MyStreamer(cred['consumer_key'], cred['consumer_secret'],
cred['access_token_key'], cred['access_token_secret'])
keywords = sys.argv[2]
stream.statuses.filter(track=keywords)
However, I want to create a UI in django framework which consist of a
'start' and a 'stop' button. What should I do to stop the twython
streaming when I clicked on the button 'stop' ? Can give me some simple
examples pls?

No comments:

Post a Comment