I am currently having problems getting an example code to use tweepy to access the Stream Streaming API to work correctly (err ... or at least as I expect it to start). I am using a recent tweepy clone from GitHub (tagged version 1.9) and Python 2.7.1.
I tried a sample code from three sources, in each case using twitter as a test term for tracking:
In all three cases, I get the same result: Authentication is successful, no errors occur, and the main program loop seems to run without any problems. I see that network utilization is hopping towards 200 KB / s, and the python process jumps to almost 100% CPU utilization, so I think the data is received. However, nothing is displayed on the console.
I suspect that the tweepy Stream class does not call a custom callback method for any reason. I tried to rewrite the callback methods in each example to output the output when they are called, which seems to confirm this. This is one very simple bit of test code based on Andrew Robinson's blog post (of course, with application keys removed):
# -*- coding: utf-8 -*- import tweepy consumer_key = '' consumer_secret = '' access_token_key = '' access_token_secret = '' auth1 = tweepy.OAuthHandler(consumer_key, consumer_secret) auth1.set_access_token(access_token_key, access_token_secret) class StreamListener(tweepy.StreamListener): def on_status(self, tweet): print 'Ran on_status' def on_error(self, status_code): print 'Error: ' + repr(status_code) return False def on_data(self, data): print 'Ok, this is actually running' l = StreamListener() streamer = tweepy.Stream(auth=auth1, listener=l)
What am I doing wrong?
source share