title: I want to set the limit of maximum number of Tweets
body: <p>I am very new to python. I'm using tweepy library to scrape tweets via twitter streaming API. but it seems like connection gets broken after running for an hour. I want to know if there is any way to stop the program from running before the connections get broken. In short limiting the tweets.</p>
  
  <p>I have tried the .items method but it did'nt work as it gives the name Error.</p>
  
  <pre><code>  from tweepy import Stream
    from tweepy import OAuthHandler
    from tweepy.streaming import StreamListener
  
  
    ckey="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    csecret="xxxxxxxxxxxxxxxxxxxxxx"
    atoken="xxxxxxxxxxxxxxxxxxxxx"
    asecret="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
  
    class listener(StreamListener):
  
      def on_data(self, data):
          print(data)
          return(True)
  
      def on_error(self, status):
         print status
  
    auth = OAuthHandler(ckey, csecret)
    auth.set_access_token(atoken, asecret)
  
    twitterStream = Stream(auth, listener())
    twitterStream.filter(track=["Obama"])
  </code></pre>
  
  <p>thanks</p>