title: Using tweepy to access Twitter's Streaming API
body: <p>I'm currently having trouble getting example code for using tweepy to access Twitter's Streaming API to run correctly (err...or at least how I expect it to run). I'm using a recent clone of tweepy from GitHub (labeled version 1.9) and Python 2.7.1.</p>
  
  <p>I've tried example code from three sources, in each case using "twitter" as a test term for tracking:</p>
  
  <ol>
  <li><p>O'Rilley Answers code: <a href="http://answers.oreilly.com/topic/2605-how-to-capture-tweets-in-real-time-with-twitters-streaming-api/" rel="noreferrer">How to Capture Tweets in Real-time with Twitter's Streaming API</a></p></li>
  <li><p>Andrew Robinson's blog: <a href="http://andrewbrobinson.com/2011/07/15/using-tweepy-to-access-the-twitter-stream/" rel="noreferrer">Using Tweepy to access the Twitter Stream</a></p></li>
  <li><p>Tweepy examples repository on GitHub (which, as Andrew Robinson has done, can be easily modified to support OAuth authentication): streamwatcher.py</p></li>
  </ol>
  
  <p>In all three cases I get the same result: Authentication is successful, no errors are produced, and the main program loop seems to be executing w/o any problems. I see network usage jump to about 200KB/s, and the python process jumps to near 100% CPU usage, so I think data is being received. Nothing is output to the console, however.</p>
  
  <p>I suspect that tweepy's Stream class is not calling the custom callback method for some reason. I've tried rewriting the callback methods in each example to produce output <em>whenever</em> they're called, which seems to confirm this. This is one very simple bit of test code based on Andrew Robinson's blog entry (with my app's keys removed, of course):</p>
  
  <pre><code># -*- 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)
  #setTerms = ['hello', 'goodbye', 'goodnight', 'good morning']
  setTerms = ['twitter']
  streamer.filter(track = setTerms)
  </code></pre>
  
  <p>What am I doing wrong?</p>