title: End python code after 60 seconds
body: <p>Below there is some fully functioning code.</p>
  
  <p>I am planning to execute this code through command line, however I would like it to end after 60 seconds.</p>
  
  <p>Does anyone know the best way of going about this?</p>
  
  <p>Thanks in advance. </p>
  
  <pre><code>import time
  class listener(StreamListener):
  
      def on_data(self, data):
          try:
              print data
              saveFile = open('twitDB.csv','a')
              saveFile.write(data)
              saveFile.write('\n')
              saveFile.close()
              return True
          except BaseException, e:
              print 'failed ondata,' ,str(e)
              time.sleep(5)
  
      def on_error(self, status):
          print status
  </code></pre>